Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Monitoring child processes

by moritz (Cardinal)
on Mar 13, 2012 at 15:12 UTC ( #959376=note: print w/replies, xml ) Need Help??


in reply to Monitoring child processes

perlipc has quite some material on handling child processes; in particular it points out that you should call waitpid for the dying child processes, so that they don't become zombies/defunct. Calling waitpid is probably more idiomatic than polling all your children.

Replies are listed 'Best First'.
Re^2: Monitoring child processes
by rovf (Priest) on Mar 13, 2012 at 15:49 UTC
    I had thought about waitpid with NO_WAIT (I have used a similar solution in a different application), but I was interested in get it to run by using kill 0. Actually, this seems to work so far, only that I didn't understand, why I had to 'IGNORE' SIGCHLD explicitly. Actually, I got the idea to use kill instead of waitpid from an example at perlipc:
    Another interesting signal to send is signal number zero. This doesn't actually affect a child process, but instead checks whether it's alive or has changed its UID.
    unless (kill 0 => $kid_pid) { warn "something wicked happened to $kid_pid"; }
    This seemed to be an attractive and easy solution - that's why I wanted to try it out.

    -- 
    Ronald Fischer <ynnor@mm.st>

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2020-12-05 00:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (63 votes). Check out past polls.

    Notices?