Question on fork(), exec(), kill()
der Mouse
mouse at thunder.mcrcim.mcgill.edu
Thu May 30 20:20:25 AEST 1991
In article <1991May15.215826.26327 at athena.mit.edu>, jik at athena.mit.edu (Jonathan I. Kamens) writes:
> You need to wait on your children to get them to go away; until you
> do that, they're zombies.
> Here's my occasionally posted article about that:
> Unfortunately, it's impossible to generalize how the death of child
> processes should behave, because the exact mechanism varies over the
> various flavors of Unix. [...]
If you just want to fork children, don't want them to bother you when
they die, don't care about preserving precise parenthood relationships,
and don't care about the return status from the wait or resource usage
or anything of the sort, you *can* do *that* portably. All you need to
do is fork and have the parent wait for the child explicitly, then have
the child fork again, with the second-level child doing the real work
and the first-level child dying immediately after the second fork.
This way, the parent has no children left, because its only child
exited. When the intermediate process died, init (PID 1) inherited the
second child and will worry about doing the wait() when it dies.
Not that this is always appropriate, but sometimes it is.
der Mouse
old: mcgill-vision!mouse
new: mouse at larry.mcrcim.mcgill.edu
More information about the Comp.unix.questions
mailing list