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.


In reply to Re: Parallel Fork Manager -- Can't kill zombies! by fbicknel
in thread Parallel Fork Manager -- Can't kill zombies! by expresspotato

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.