in reply to Parallel Fork Manager -- Can't kill zombies!
I think the source of this problem was correctly identified (i.e. only the ->start method waits for children &ENOHANG), but I didn't see a solution.
Here's a suggestion. It uses a method that isn't documented called ->wait_one_child. If you call it with ->wait_one_child (&ENOHANG), it behaves just like waitpid(), but also calls your run_on_finish callback.
I'm guessing that calling this method from outside the module wasn't in the design, but it seems to work ok for me. I, too, had an application where the parent was waiting for queue work, so didn't use ->start on a periodic basis. With this, you can either call ->wait_one_child periodically to reap children and run their callbacks, or you can design in some other event to do the same thing.
Call it in a loop (again, just like waitpid()) to get all the zombies reaped. See the docs for waitpid() in the Perl docs for sample code.
|
|---|