tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: SIGCHLD and sigaction()



> When I install a SIGCHLD handler via sigaction() using SA_SIGINFO, is
> it guaranteed that my handler is called (at least) once per
> death-of-a-child?

"Maybe."  It depends on how portable you want to be.

Historically, "no": in some older systems, a second SIGCHLD delivered
when there's already one pending delivery gets, lost same as any other
signal.

Then someone - POSIX? SVR4? I don't know - decided to invent a flavour
of signal that's more like writes to a pipe: multiple of them can be
pending at once.  Some systems decided this was sane and implemented
it.

Personally, I don't like it; I think signals should be much like
hardware interrupts in that a second instance happening before the
first is serviced gets silently merged.  If you want some sort of
queued notification of child death, it seems to me a much righter, much
more UNIXy, tack to take is to add something like AF_CHILD sockets or
some such and get child death notifications that way.  (Actually, I'm
not sure sockets would work without severe hackery; too much of the
socket machinery assumes the data in a socket is independent of who
reads from it.  Perhaps it would need a new flavour of file descriptor,
akin to kevent or timerfd descriptors.  I have no doubt it could be
done one way or another.  But arguably it's best to just use SIGCHLD
and a loop that uses WNOHANG.)

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index