I have lots of code for using signals to control forked children. Since about 3-4 years ago, I have stopped using signals and that code! Trying to have the same Perl script be able to run on different *nixes just doesn't work like it used to.
What I have found to work very well for me is to use 'kill 0' in the parent code to tell if the child still exists I use 'usleep' to wait for a few milliseconds between tests in a 'while (1)' loop. I keep the child pids in a hash with the values being the initial time of the fork. I usually test for the memory usage of each child and if it starts to grow too quickly, I try to halt it gently and if it doesn't exit than I force kill the process. (Note: That hasn't happened yet, but it may.)
I'm not saying you can't get it to work on one distribution of *nix, but it seems that the different vendors are *impoving* the signal process all the time :-). YMMY.
Update: Corrected 'fork 0' to 'kill 0' as AM noticed.
Regards...Ed
"Well done is better than well said." - Benjamin Franklin
In reply to Re: Managing the fork/execing and reaping of child processes
by flexvault
in thread Managing the fork/execing and reaping of child processes
by ibm1620
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |