Ignore <Ctrl-D>

Not Marc Spencer goehring at gnu.ai.mit.edu
Tue Mar 26 05:46:02 AEST 1991


In article <1991Mar25.011538.11226 at cs.umu.se> dvldbg at cs.umu.se (Daniel Brahneborg) writes:

   >I'm doing a menu in C, and trying to ignore <Ctrl-d> <Ctrl-c>
   ><Ctrl-z> etc.  In other words, I would like the program not to be
   >interrupted until user select 'Quit' from the menu. (If I press
   ><Ctrl-d> when the program is waiting for user to select the menu,
   >the program will go to infinite loop)

   There are as far as I know two ways of doing this. The easiest way
   is to use the signal(3) call, or maybe the underlying system call,
   and tell it to ignore SIGSUSP, SIGINTR, SIGTERM, and a few others.
   Or if you prefer, call one of your own routines.

this won't help, much.  at the very least even if you do catch sigint
it will still abort any i/o in progress.

   The other way is to manupulate the terminal handler, which sends
   the above mentioned signals. By calling ioctl(), you can set a lot
   of things, which I leave you to discover for yourself.

this will.  he needs to put the terminal into raw mode if he wants the
terminal handler not to produce signals, which is imho infinitely
better than trying to catch all those signals.
--
		  Help stamp out vi in our lifetime!
	Scott Goehring			goehring at gnu.ai.mit.edu
	On exile in Indianapolis, IN



More information about the Comp.unix.programmer mailing list