List of routines safe to use in signals?
Robert Coren
coren at osf.org
Wed Dec 19 01:59:53 AEST 1990
In article <1990Dec18.013608.8234 at scuzzy.in-berlin.de>,
src at scuzzy.in-berlin.de (Heiko Blume) writes:
|> ...what does sigsuspend(2) *really*
|> do? say, i block SIGCHLD. A child dies. The signal get's posted
|> to the parent. since it's blocked it's "pending". ok, what happens when
|> i call sigsuspend() then, with a mask all zeroes. the man page says it
|> suspends the process until the *delivery* of a signal not masked by
|> sigsuspend()'s argument. guess what, although the signal is pending,
|> the process gets blocked! WHY? [anyway, i'll elaborate on this in
|> another posting due soon...]
The specification of sigsuspend()'s behavior with respect to signals
that are *already* pending when a program calls sigsuspend() do seem
to be a little vague. I don't have POSIX 1003.1 handy at the moment,
but I took a look at the OSF/1 manpage, and it seems to contain at
least an implication that such a signal is delivered when you call
sigsuspend() (assuming the mask specified in sigsuspend() unmasks the
pending signal). I also took a quick look at the OSF/1 *code*, and
this is in fact what it does.
It may be that your system's implementation interpreted the spec for
sigsuspend()) differently, or it may just be wrong.
Another possibility (admittedly remote) comes to mind. I would assume
that you have set up a handler for SIGCHLD, since you seem to be
interested in its delivery. Is this in fact the case? Have you
confirmed that the SIGCHLD signal is in fact pending (try using
sigpending())? The reason I ask this is that the default behavior for
SIGCHLD is SIG_IGN, in which case it would have vanished silently when
it was posted.
|> ...as far as i get it,
|> the BSD sigpause(2) is equivalent to posix sigsuspend(2), so what
|> has sigpause(2) to do in a posix environment anyway?
A system that implements sigsuspend() maintains sigpause() for
compatibility with "older" systems; they are essentially equivalent. A
potential difference is that the mask given to sigpause() is an int,
where as that given to sigsuspend() is a sigset_t; a system that
implements more than 32 signals (as AIX does, I believe) can define
sigset_t in such a way that sigsuspend() can mask any combination of
signals, but sigpause() can only mask signals with numbers in the
range 1 <= s <= 32.
Robert
More information about the Comp.unix.programmer
mailing list