Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Monitoring child processes

by repellent (Priest)
on Mar 14, 2012 at 05:41 UTC ( #959519=note: print w/ replies, xml ) Need Help??


in reply to Monitoring child processes

kill(0, $pid) will return true even if the $pid process is a zombie. By setting $SIG{CHLD}='IGNORE'; before forking, you're having the parent process reap the zombie child upon receiving SIGCHLD, causing your call to kill(0, ...) to then work as expected.

I believe (someone correct me please) that the default perl handler for SIGCHLD is to do nothing. It is left up to the programmer to reap the child processes manually (via waitpid, or setting 'IGNORE').

    In a loop, testing the aforementioned condition, and killing the childs if the condition is met

Even after killing the children (e.g. kill(9, $pid), though I hope you're nicer with kill(15, $pid)), you still need to reap them. You're doing fine since you set 'IGNORE'.


Comment on Re: Monitoring child processes
Select or Download Code
Re^2: Monitoring child processes
by Marshall (Prior) on Mar 14, 2012 at 06:06 UTC
    I believe (someone correct me please) that the default perl handler for SIGCHLD is to do nothing. It is left up to the programmer to reap the child processes manually (via waitpid, or setting 'IGNORE').

    Yes, I think that is right.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://959519]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-09-21 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (172 votes), past polls