So you want to exit all children when you get the signal? Or just the child that recieved the signal?

Finishing a child is easy enough - you can call the $pm->finish if (...signal...).

To kill all children you'll have to keep a track of the currently active pids for the children and kill them yourself, Parallel::ForkManager doesn't have built in facilities for this ( as far as i am aware at least! ). Information on how to do this can be found in : Parallel::ForkManager question.

I am not sure what the best way to set off the infanticide would be though, I guess having a subroutine which accesses the list of pids, but there might well be stability issues, i.e. the child calls the sub, which kills the child... so you would have to make sure it is the original parent process that does the killing, and i am not sure how you would do this.

This way seems nasty though, and hopefully someone has a better idea!

Just a something something...

In reply to Re: Stop fork in Parallel::ForkManager by BioLion
in thread Stop fork in Parallel::ForkManager by casimo

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.