http://qs1969.pair.com?node_id=79776


in reply to Re: Re: Have children maintain themselves or main script maintain children.
in thread Have children maintain themselves or main script maintain children.

There are several disadvantages to installing a SIGCHLD handler

Some of the examples in The Perl Cookbook have the correct waitpid in a loop in the SIGCHLD handler, but some don't (for instance the section on a preforking daemon).

Personally I would ignore SIGCHLD and make the parent wait() for the children to die. It will be nicely blocked (ie not using any excess CPU) until it needs to do something (ie make more children).

  • Comment on Re: Re: Re: Have children maintain themselves or main script maintain children.

Replies are listed 'Best First'.
Re: Re: Re: Re: Have children maintain themselves or main script maintain children.
by the_0ne (Pilgrim) on May 11, 2001 at 21:50 UTC
    Thanks for the explanation. We HAVE run into your first bulletpoint. We had some children come back that gave us the pid instead of 0 or -1 and had to work around that. So, I can understand your explanation there.

    for instance the section on a preforking daemon

    I'm almost positive (I don't have the book here with me today.) that the preforking daemon is the major example we used and you're right, it does not have the waitpid. We got lucky and found that in a post on good old PM.

    Personally I would ignore SIGCHLD and make the parent wait() for the children to die. It will be nicely blocked (ie not using any excess CPU) until it needs to do something (ie make more children).

    gr0k and I were just talking about that. I think my weekend project has just shown up. :)

    Thanks to everybody that has helped out with this node.