[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] Perl, fork, and waitpid()



On Apr 19, 2009, at 5:42 PM, Dan Linder wrote:
I've tried using "waitpid(-1,WNOHANG)" thinking that would return the PID of the last child to die, or "-1" if none had died since last checking, but that seems to just hang _waiting_ for the next death to happen... I did a "waitpid($pid_of_a_child, 0)" but tha just waits until that specific child dies.

Anyone have any example code that can do this?

We use POE for things like this. Specifically, this cookbook recipe:

http://poe.perl.org/?POE_Cookbook/Child_Processes_3

There's a pretty active IRC channel that can help if you get stuck (irc.perl.org #poe). I'm sure there's mailing lists too.

I got somebody started from scratch last week and he seemed to take to it pretty quickly.

HTH,

j


POE::Wheel::Run for the win!  :)