Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2022-05-18 04:00 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (68 votes). Check out past polls.