Path: utzoo!attcan!uunet!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!ub!rutgers!netnews.upenn.edu!weisen@eniac.seas.upenn.edu From: weisen@eniac.seas.upenn.edu (Neil Weisenfeld) Newsgroups: comp.lang.c Subject: Re: Catching ^C and ^Z Message-ID: <29167@netnews.upenn.edu> Date: 5 Sep 90 03:55:20 GMT References: Sender: news@netnews.upenn.edu Reply-To: weisen@eniac.seas.upenn.edu (Neil Weisenfeld) Organization: University of Pennsylvania Lines: 33 In-reply-to: deen@utopia.rutgers.edu (Cinnamon Raisin) In article , deen@utopia (Cinnamon Raisin) writes: > >Hi boys and girls, > > I am trying to write a quick programme to lock a terminal(TTY) > when I leave it. Essentially I want to capture all the > interrupts that can be sent from the keyboard, such as > SIG_INT,SIG_QUIT and so on. The only reasonable thing I've > found that lets me do this is ioctl(). [stuff deleted] I remember doing this a while ago. What UNIX are you running? Under BSD, you should be able to do something like: signal(SIGINT,SIG_IGN); signal(SIGQUIT,SIG_IGN); to IGNore the signals. Using SIG_DFL should return them to their default handlers. You can also substitute a pointer to a handler of your own. Take a look at signal(3) and sigvec(2). Neil _____________________________________________________________________________ ( ) _ ( ) Neil Weisenfeld | 3900 Chestnut St. ( )(_)_ ( ) Computer Science and Engineering | Apt. 233 ( ) (_)_ ( ) School of Engineering and Applied Science | Philadelphia, PA ( ) (_)( ) University of Pennsylvania | 19104 (_) (_) Class of 1991 | ----------------------------------------------------------------------------- -- _____________________________________________________________________________ ( ) _ ( ) Neil Weisenfeld | 3900 Chestnut St. ( )(_)_ ( ) Computer Science and Engineering | Apt. 233 ( ) (_)_ ( ) School of Engineering and Applied Science | Philadelphia, PA