Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

The root problem, which is extremely difficult to deal with, is basically a race-condition:   the parent might “determine” the status of a child, but, before it can react to the status that it has thusly determined, the status of the child has changed.   Strictly speaking, you don’t even know that your list-of-children is instantaneously correct.

Obviously, the most desirable thing to do would be to schlep the entire responsibility off to an existing known-good CPAN module, such as, say, Parallel::ForkManager.   Can you find a way to do that?

Otherwise, I suggest that you should devise that the only role of the parent process/thread should be “to run the nursery.”   All of the other responsibilities, including checking whether a particular condition has occurred, ought to be the responsibilities of children.   If that special child informs you that, indeed, “ka-ka has occurred,” the parent should respond by issuing a signal to every one of its children that asks them to “please die, as soon as you possibly can,” then waits for them all to do so.   It does not poll them to see if they are alive:   it does not have to.   If at all possible, it also does not kill them.   (How messy ... and, how unpredictable.   Each child, once alive, is responsible for setting its own affairs in order upon the occasion of its own death... timely or otherwise.)

I have consistently found (and, maybe it’s just me ...) that if you try to give the parent process many responsibilities of its own to take care of in addition to “watching the kids,” the kids get into trouble in ways that you could not possibly have anticipated and could never reproduce.   (This being a case in which computers imitate real life!!)

In reply to Re: Monitoring child processes by sundialsvc4
in thread Monitoring child processes by rovf

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (5)
    As of 2020-12-04 08:51 GMT
    Find Nodes?
      Voting Booth?
      How often do you use taint mode?

      Results (58 votes). Check out past polls.