SPUG: Forked Children talking back to the parent?

dancerboy dancerboy at strangelight.com
Wed Jan 17 13:39:56 CST 2001

At 8:28 AM -0800 1/17/01, Richard Wood wrote:
>I do something very similar to this, and I still have
>a dilemma with it.  What I do is to find out how many
>processes I need to fork, then I set up bidirectional
>socket-pairs to use between the parent and children,
>then I fork the children.  The parent then goes into a
>loop of sending messages to every child followed by a
>loop of waiting for a response from every child prior
>to going on to the next message.  The parent is in an
>outer loop of looking for and processing scripts which
>may or may not have commands for every child process.
>If a child process is not supposed to receive a
>command, I just send it a DUMMY command which it echos
>The children are in a loop waiting for messages from
>the parent upon which they take action and report back
>to the parent.
>The part I haven't worked out is what to do if a child
>hangs.  Hopefully, other responses to your email will
>give me some ideas on that.

One thought:  instead of sitting in a loop waiting for messages from 
the children, what if the children send a signal ( via kill() ) to 
let the parent know that the child has data for it?

I assume you're aware of the use of $SIG{__ALARM__} to time-out 
operations that would otherwise block?


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/

More information about the spug-list mailing list