USG 5.0 r2: can my program tell if i

dan at haddock.UUCP dan at haddock.UUCP
Tue Aug 14 13:41:50 AEST 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.



More information about the Comp.unix.wizards mailing list