Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!hp4nl!dutrun!vlruo02 From: vlruo02@dutrun.UUCP (Ge van Geldorp) Newsgroups: comp.sys.ibm.pc Subject: Re: Ctrl-C Echo Summary: get ctrl-c.c Keywords: ctrl-c trapping, SIGINT Message-ID: <677@dutrun.UUCP> Date: 4 Apr 89 16:11:27 GMT References: <1167@optilink.UUCP> <7542@fluke.COM> Reply-To: vlruo02@dutrun.UUCP (G.v.Geldorp) Organization: Delft University of Technology, The Netherlands Lines: 42 In article <7542@fluke.COM> mason@tc.fluke.COM (Nick Mason) writes: >In article <1167@optilink.UUCP> cramer@optilink.UUCP (Clayton Cramer) writes: >>I'm using signal(SIGINT, SIG_IGN) to disable control-C processing from >>an application, and it works. But the second and third times I type >>control-C, the ^C\r\n are echoed to the screen, even though there is >>no control-C processing taking place. Any idea who is producing the >>screen output, and how to stop it? > > >I'm doing something similar in my code to capture ctrl-C. The capture >works great, but as you also found ^C\r\n is echoed to the screen. > >After looking into this a great deal I believe that the echo is coming >from the BIOS and the INT9 keyboard interrupt handler. If this is >true then the only way to get rid of it is to write your own >keyboard handler routine. It's the CON device driver which writes the ^C\r\n. The good news is that there are ways to avoid this. If you want to disable Ctrl-c completely, get the CTRL-C.C package from SIMTEL20. The routines in this package (which was written by John Galvin, galvin@circle.UUCP) basicly put the CON device in raw mode, using dos function 0x44 (IOCTL). If you want to act upon ctrl-c, but have the ^C\r\n suppressed, things are slightly more difficult. The ^C\r\n string is written to standard output. If you can do without standard output, open the NUL device. Use the file descriptor obtained from this call with a dup2 call to have stdout redirected to NUL. Now, the CON driver can write ^C\r\n if it wants to, but it won't end on your screen. Code fragment: int nulfh; nulfh = open("nul", O_WRONLY, 0644); /* get new file descriptor */ fflush(stdout); /* flush any remaining chars */ dup2(nulfh, 1); /* redirect stdout to NUL */ close(nulfh); /* clean up */ Hope this helps. Ge van Geldorp. (...!mcvax!hp4nl!dutrun!vlruo02)