Subj : Re: sigwait on HPUX misses SIGCHLD To : comp.programming.threads From : roger.faulkner Date : Mon Oct 10 2005 09:21 am Ewan Manamohan wrote: > Hi, > > I am in the midst of writing a multithreaded scheduler application. > When I fork out 8 children, sigwait only captures 7 of them at times. I > have sigwait running waiting for SIGCHLDs as a thread. The other > threads have SIGCHLD blocked. > > It only happens on HPUX . It works fine on SUN. > I am using HPUX 11.11i. > > Anyone has any idea why this is happening ? You are not guaranteed to receive one SIGCHLD signal for every child process that has terminated. You are only guaranteed to receive at least one SIGCHLD for a group of terminated children. Your SIGCHLD handler should attempt to reap as many children as possible, using waitpid(-1, &stat_loc, WNOHANG) in a loop until it fails to reap anything. That way you will miss no terminated children. The SIGCHLD handler should expect to reap 0, 1, or more children on each receipt of SIGCHLD. Roger Faulkner Sun Microsystems .