1. If the level 1 child exits, then its level 2 children will send their signals back to the level 0 process. Therefore either the level 0 process must remember which children to ignore, or else the level 1 child must not exit until after all of its children are accounted for. (kill may help.)
  2. The level 1 child should use select and sysread to try to read from all kids in parallel, or else the level 2 children should call getppid and then send a signal when they are ready to write. Using exit signals is not safe because it is possible that a child's exit may be blocked indefinitely on the fact that its write back to its parent filled a buffer that needs to be read before more can be written.

More advice. Either plan on the final result not being portable to Windows or else use POE. (The latter is not guaranteed, but at least has a chance.) Give careful consideration to race conditions and plan carefully for handling inevitable errors; this is going to be tricky.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to Re: On handling multiple generations and data between them by Ovid
in thread On handling multiple generations and data between them by atcroft

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.