atcroft has asked for the wisdom of the Perl Monks concerning the following question:
A friend came to me with a problem regarding multiple generations (levels) of child processes when forking that has stumped my poor store of information, and so I present the query to thee, hoping to increase in knowledge to answer. The questions follow the background information below.
Background
My friend is writing a client-server process that involves multiple levels of children. While I am not privy to the internals of the project, I can provide the following basic information on the flow, which he agreed to allow me to post.
Part 1
How to prevent the SIGCHLD resulting from the exit of a level 2 child from being seen by the level 0 (grand)parent? It was my guess to redefine the handler routine pointed to for SIGCHLD, but is there anything at that point that could cause the signal to be propagated back to the level 0 process, other than the possibility it might be the last of the level 2 processes being waited upon by the level 1 process that spawned them? I would think in that case it would be a different instance of SIGCHLD.
Part 2
How can the data from a level 2 child best be returned to its level 1 parent without blocking the parent from getting the data from another child responding quicker? Or from the level 1 child to the level 0 (grand)parent without blocking it from responding to further incoming requests? Could/should either of these be handled in the SIGCHLD handler(s)? From the way it was described, it seems as if there is the possibility that a large number of level 1 children might at times exist, each spawning a number of level 2 children, so I would be concerned that using pipe() or the forking form of open() might resulting in opening too many file handles, and I am not sure what OS this may be loaded on (various forms of *nix certainly, although I think there was mentioned the possibility it might be run on some form of Windows, or possibly other systems as well), so I am not sure IPC::Shareable would be an option either.
Part 3
Would it be possible for the SIGCHLD handler defined at a particular parent-child level (0-1 or 1-2) to be able to interact with or initiate changes in data that that parent level (0 or 1, respectively)?
Any wisdom and/or instruction in these matters would be greatly appreciated.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: On handling multiple generations and data between them
by Zaxo (Archbishop) on Aug 18, 2002 at 17:19 UTC | |
Re: On handling multiple generations and data between them
by Ovid (Cardinal) on Aug 18, 2002 at 18:00 UTC | |
Re: On handling multiple generations and data between them
by PhiRatE (Monk) on Aug 19, 2002 at 00:46 UTC |