in reply to Re^3: Forking child processes.
in thread Forking child processes.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Forking child processes.
by sojourn548 (Acolyte) on Sep 19, 2009 at 03:32 UTC | |
In order to debug this problem, I've trimmed the code to bare minimum, and I am now trying ikegami's solution. The subroutine, tick(), is now called every 10 second interval without the need for the signal handler. However, I am still seeing issues with the callback not being called for every forked process. In this example, only the first process gets the callback. Here is the sample code that I am testing. I am hoping that it's something trivial that I've overlooked. Maybe a good night's sleep will help me find the problem. Please let me know if you see something that I am not doing correctly. Assuming you have the modules installed, this code should run as is.
| [reply] [d/l] |
by sojourn548 (Acolyte) on Sep 22, 2009 at 06:13 UTC | |
I think what's happening is that the process that calls tick() is exiting before the three exec(@ping_cmd) has a chance to return (which has the effect of only some of the run_on_finish() are getting a chance to run). The callback now runs for ALL child processes by calling $pm->wait_all_childern; Since I am waiting on all children, I am probably not creating any defunct processes from tick().. which doesn't really matter since not calling wait_all_children had the effect of exiting immediately and the defunct child processes would have been inherited by init. Is this correct?
| [reply] [d/l] |