[net.unix-wizards] Missing a signal and pausing forever

msc@qubix.UUCP (07/07/83)

	The article about missing the alarm signal and pausing forever
	shows up a general problem with signals.  It is possible
	for a signal to be generated after a program tests some
	condition and before it pauses thus causing the program to
	pause forever.  The system does NOT have to be heavily loaded
	for this to happen.  It happened to me when I was the only user
	on a Sun.

	It seems that signals need to be treated even more like
	hardware interrupts.  One should be able to disable them and
	have signals sent during the disabled period saved for when
	they are enabled again.
-- 
	Mark
	...{decvax,ucbvax}!decwrl!qubix!msc
	...{ittvax,amd70}!qubix!msc
	decwrl!qubix!msc@Berkeley.ARPA

guy@rlgvax.UUCP (07/09/83)

4.?BSD does have such a facility for "raising the interrupt priority" of a
process and lowering it later, with the new signal mechanism.  Saying

	sigsys(sig, SIG_HOLD);

causes the signal to be remembered if it occurs, but not be presented to
the process; if the process changes the action for the signal, it is presented
to the process (or discarded if the action is changed to SIG_IGN).  Furthermore,
you set the "interrupt new PSW" for the signal to set the signal to SIG_HOLD
rather than SIG_DFL by saying

	sigsys(sig, DEFERSIG(routine));

which means that the signal action is reset to SIG_HOLD when "routine" is
entered.  There are also facilities for dismissing signals more cleanly.

The UNIX signal mechanism does need work to make it useful for general
inter-process communication; UNIX also needs block-wakeup and message
mechanisms, both of which are in USG UNIX 5.0 (semaphores, message queues)
and the latter of which is in 4.1c/4.2BSD - the former can be simulated under
4.1c/4.2 with exclusive-use opens on a file.  4.1c/4.2 also has a more
elaborate signal mechanism.

	Guy Harris
	{seismo,mcnc,we13,brl-bmd,allegra}!rlgvax!guy

jmc@root44.UUCP (07/11/83)

Personally I think that signals, along with file security are the two most
mis-designed features of UNIX.  In addition to missing a signal as described,
you can get botches due to a second signal arriving, and not getting caught,
before you have reset the catch routine.  Then you can have them arriving
in some other order from that in which they were sent because of the
numerical ordering.  Then you get botches like 'interrupted system call' to
worry about on your I/O.

			John Collins
			Root Computers Ltd
				...!vax135!ukc!root44!jmc