Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!ihnp4!zehntel!dual!amd!decwrl!decvax!cca!ima!haddock!dan From: dan@haddock.UUCP Newsgroups: net.unix-wizards Subject: Re: USG 5.0 r2: can my program tell if i Message-ID: <227@haddock.UUCP> Date: Mon, 13-Aug-84 23:41:50 EDT Article-I.D.: haddock.227 Posted: Mon Aug 13 23:41:50 1984 Date-Received: Thu, 16-Aug-84 01:45:05 EDT Lines: 16 Nf-ID: #R:burl:-52200:haddock:16800023:000:673 Nf-From: haddock!dan Aug 13 15:23:00 1984 > What you should do is check to see if SIGINT was already being ignored > when you try to handle it. (This indicates that you're in the background.) > If it was being ignored, reset it to that state. > > if (signal(SIGINT, clean_routine) == SIG_IGN) > signal(SIGINT, SIG_IGN); Right description, wrong code. You've left a hole; if the signal arrives after the first signal() call and before the second, it will get caught even though it was ignored initially. The correct code is if (signal(SIGINT, SIG_IGN) != SIG_IGN) signal(SIGINT, clean_routine); This is explained in Brian Kernighan's document on UNIX programming that comes with many (all?) UNIX systems.