Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Monitoring child processes

by repellent (Priest)
on Mar 14, 2012 at 05:41 UTC ( [id://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'.

Replies are listed 'Best First'.
Re^2: Monitoring child processes
by Marshall (Canon) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://959519]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-29 06:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found