Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Reaping Zombiesby dsb (Chaplain) |
on Feb 15, 2006 at 18:04 UTC ( [id://530459]=perlquestion: print w/replies, xml ) | Need Help?? |
dsb has asked for the wisdom of the Perl Monks concerning the following question:
Hey all,
I'm writing a script that needs to fork() and i want to be sure that I'm cleaning up all my zombies.
Between perlipc and Programming Perl, I've gotten a bit of zombie reaping code that I mostly understand, but need some clarification on. The code I'm using is: Because I'm not all that familiar with waitpid() - or wait(), for that matter - I'm not clear on whether or not this code has the parent process hanging around until child processes are reaped. Also, I'm not sure if this is preventing the script from fork()'ing another process before previous children are reaped. Finally, would I be better off just running the reaper() function w/o checking for zombies first, so that the script constantly is checking on child procs. The docs for waitpid() said that it could return 0 if child procs are still running, which seems like it might be helpful insofar as making sure child processes are reaped before the parent exits. This seems like it would account for any scenarios where the parent process finished it's logic and exits before receiving a CHLD signal. UPDATE: The cookbook has a pretty good bit on reaping zombies. Three things cleared up in recipe 16.19 of The Cookbook First Edition.
dsb This @ISA my( $cool ) %SIG
Back to
Seekers of Perl Wisdom
|
|