System V / SIGCLD questions...

Erik Murrey murrey at lehi3b15.csee.Lehigh.EDU
Fri May 12 03:37:33 AEST 1989


Here's one I can't figure out...

I'm writing a routine (like reapchildren(), found all over the place
in BSD code), using the SIGCLD signal to invoke it.  Its job is to
execute a wait(2) on all of the children that have died, getting their
exit status, etc.

Now for the problem:

It seems (according to the man page for signal(2)) that during the
signal handler for SIGCLD (reapchildren()), any further SIGCLD's will
be ignored.  By the same token, I can't do a non-blocking wait() in
System V, so I can't repeatedly call wait() (I might have other
children that haven't exit()-ed yet)

Here is what happens:

If I have spawned a few children, and one just did an exit(), then my
reapchildren() signal handler gets called.  It does a wait(), gets the
exit status, and gets out of there (after resetting the SIGCLD
signal).  If by chance a second child dies while we are within the
reapchildren() handler, I never get notified of it...

How can I get around this?   If only I had wait3()...


... Erik
-- 
Erik Murrey
Lehigh University
murrey at csee.Lehigh.EDU
erik at mpx.com



More information about the Comp.unix.wizards mailing list