Path: utzoo!attcan!uunet!husc6!uwvax!oddjob!gargoyle!att!chinet!mcdchg!usenet From: davek@heurikon.UUCP (David Klann) Newsgroups: comp.unix Subject: Re: Children's exit() status Message-ID: <7963@mcdchg.UUCP> Date: 20 May 88 15:43:38 GMT References: <4626@mcdchg.UUCP> Sender: usenet@mcdchg.UUCP Organization: Heurikon Corp., Madison, WI. Lines: 38 Approved: usenet@mcdchg.UUCP In article <4626@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