signals

Bob Lenk rml at hpfcdc.HP.COM
Sat Mar 4 11:28:26 AEST 1989


> Does Unix make any guarantees about when a signal will be delivered?  The
> man page for kill doesn't say anything about this in any of the versions
> at my disposal.

In all implementations I know of a signal sent by a process to itself
will be delivered before kill() returns, with one possible exception.
If the process happens to receive some other signal that it is catching
with exactly the right timing, it is possible that it will execute the
signal handler for that other signal and then return from kill() without
delivering the signal sent by kill().  This possibility exists in
most non-reliable signal implementations (eg. V7, SVR2).  It does not
exist in 4.2 or 4.3.  I'm not sure about 4.1 or SVR3 (with their
variant of reliable signals).

This is not mentioned in any manual I know of.  POSIX (IEEE 1003.1) states:

	If the value of _pid_ causes _sig_ to be generated for the
	sending process, either _sig_ or at least one pending
	unblocked signal shall be delivered to the sending process
	before the kill() function returns.

It also has similar wording for sigprocmask() (similar to sigsetmask()
in 4.2/4.3 or sigrelse() in 4.1/SVR3).

> Looking at the man page actually confused me further.  My manuals for
> 4.1BSD, 4.2BSD and SunOS4.0 claim that kill(0, sig) sends sig to all
> *other* processes in the process group (SunOS4.0 is particularly
> explicit about this).  4.3BSD and SunOS 3.2 just say all processes in
> the process group.  Presumably the latter description is the correct
> one for all these systems?

It appears to be correct for at least 4.2 and 4.3.  For kill(-1, sig)
the calling process is not sent the signal in these systems, but is
sent the signal in System V.  Much time was spent agonizing over that
difference in POSIX deliberations, but no one ever questioned that
kill(0, sig) goes to the whole pgrp including the sender (which POSIX
requires).  I'd never noticed that in the 4.2 manuals before.

>                             (Sixth edition refers to "all other
> processes which have the same controlling typewriter".)

And furthermore makes the statement that "In no case is it possible for
a process to kill itself".  It's not clear if that is only supposed to
refer to a pid of 0, or even to an explicit kill(getpid(), sig).  I
don't have V6 source handy.

		Bob Lenk
		hplabs!hpfcla!rml
		rml%hpfcla at hplabs.hp.com



More information about the Comp.unix.questions mailing list