- 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.)
- 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.