From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f678f,bee968b4f86bfc67 X-Google-Attributes: gidf678f,public From: stmartin@stmart.cxo.dec.com (Andy St Martin) Subject: Re: How to ignore SIGCLD and not produce zombies? Date: 1996/09/16 Message-ID: <51k6r0$76o@nntpd2.cxo.dec.com>#1/1 X-Deja-AN: 180973911 references: <51c1mr$58s@pt9201.ped.pto.ford.com> organization: Digital Equipment Corp. newsgroups: comp.unix.osf.misc In article <51c1mr$58s@pt9201.ped.pto.ford.com>, Bryan Miller wrote: > I have a server that listens to a well know port and forks > off children upon request. Since the server cannot wait > for the children to die before going back to the port to > listen, it produces defunct (zombie) processes. > > Isn't there a way to start the server with SIGCLD set > to ignore? If you really don't want to be notified with SIGCLD, you can periodically call waitpid() to "reap" the exited children. Something like: while ((pid = waitpid(-1, &status, WNOHANG)) != -1) { /* do stuff for cleaning up dead children */ } This should clean up all the Zombies and not hang if one or more child processes are still active. This should work for Digital UNIX, Sun and HP-UX. Andy St.Martin stmartin@stmart.cxo.dec.com