[comp.os.minix] bug in check_sig

bal@cs.vu.nl (Henri Bal) (09/30/87)

The procedure check_sig in the file mm/signal.c contains the following  bug.
If the signal to be checked is a SIGALRM, the statement on line 6617 (of the
original Minix Source Code contained in the book) causes the ALARM_ON bit
of every single process to be cleared. So, if an alarm goes off in one process,
all other processes that are sleeping will hang forever, because of the test
on line 6616. As an example, if you give the commands:
	
	(sleep 20; echo A) &
	(sleep 4; echo B) &

only a ``B'' will be printed. The ``sleep 20'' will never terminate.

To fix the problem, line 6617 should only clear the ALARM_ON bit if
send_sig is TRUE, so it should be changed into:

	if (send_sig) rmp->mp_flags &= ~ALARM_ON;

Also note that the semantics of the alarm signal are subtly different from
the Unix semantics. In Unix, if you explicitly send an alarm signal
(e.g., by ``kill -14 pid'') to a process that is not sleeping, the process
will be killed. In Minix, the signal will be ignored (because of line 6616).