Need help spawning a child
Jonathan I. Kamens
jik at athena.mit.edu
Thu Jun 22 09:48:46 AEST 1989
In article <873 at cbnewsl.ATT.COM> dune at 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 <signal.h>
main()
{
...
signal(SIGCHLD, handler);
...
}
handler()
{
wait(0);
}
Jonathan Kamens USnail:
MIT Project Athena 432 S. Rose Blvd.
jik at Athena.MIT.EDU Akron, OH 44320
Office: 617-253-4261 Home: 216-869-6432
More information about the Comp.unix.questions
mailing list