Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: Re: Need help spawning a child Message-ID: <12131@bloom-beacon.MIT.EDU> Date: 21 Jun 89 23:48:46 GMT References: <1661@apt.UUCP> <873@cbnewsl.ATT.COM> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: jik@athena.mit.edu (Jonathan I. Kamens) Distribution: usa Organization: Massachusetts Institute of Technology Lines: 37 In article <873@cbnewsl.ATT.COM> dune@cbnewsl.ATT.COM (Greg Pasquariello) writes: >Simply use signal() to ingnore the death of a child. In SVR3.2 this will >have the desired effect of letting the child die without creating >zombies. I can't speak for SVR3.2, but I can tell you for sure that this will not work under BSD (in fact, I just checked with a five line program). The method I use under BSD to accomplish this is a bit more convoluted, but it just *might* be a bit more portable (I'm not sure, because I've done very little work under anything other than BSD and the SysV machine I have an account on is down right now :-). Under BSD, you set up a signal handler which responds to SIGCHLD by calling wait(0). The return value of the wait() call is irrelevant -- it serves only to tell the kernel that it can free up the resources reserved for the zombie child. #include main() { ... signal(SIGCHLD, handler); ... } handler() { wait(0); } Jonathan Kamens USnail: MIT Project Athena 432 S. Rose Blvd. jik@Athena.MIT.EDU Akron, OH 44320 Office: 617-253-4261 Home: 216-869-6432