Children's exit() status

David Klann davek at heurikon.UUCP
Sat May 21 01:43:38 AEST 1988


In article <4626 at mcdchg.UUCP> you write:
|
|  Okay UNIX Sys V hackers, here's a question for you.
|  In the following scenario, how should a parent process
|  wait for it's children to complete:
|
|  
|POSSIBLE SOLUTIONS:
|
|  Here's what I've though of so far:
|
|  There seem to be 2 types of solutions, either use wait() with or
|  without SIGCLD, or use blocking message receives.
|  
|  I'd like to use wait(), because the children have a meaningful
|  exit status.  The question is, is it possible that my program
|  be woken up only 20 times, for 30 children.  Ie. could I miss
|  child deaths because several occur "simultaneously".  (simultaneously
|  meaning while I'm awake checking one child's return code, another
|  2 children die -- the next wait() missing one or both of them.)

I've recently finished porting BSD csh(1) to System V Rel. 3.0.  I
agree that using wait(2) with SIGCLD is a possibly bad way to go
becaus of the warnings in signal(2), but I used it anyway.

The way to ensure catching all of your children is to use the Release
3 sigset(2) group of calls (I assume you're running Release 3).  Use
sigset( SIGCLD, function ) to trap SIGCLD.  Then when you wait() and
receive the first SIGCLD the system will automatically SIGHOLD all
SIGCLD signals.  Before leaving your signal catching function be sure
to call sigrelse() to release any held SIGCLD signals.

If you're not running Release 3 I'd suggest you use the message based
soltion.

Good Luck!
David Klann
{ihnp4 | uwvax}!heurikon!davek



More information about the Comp.unix mailing list