Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: multiple fork()

by Rhandom (Curate)
on Apr 16, 2001 at 23:10 UTC ( [id://72903]=note: print w/replies, xml ) Need Help??


in reply to Re: multiple fork()
in thread multiple fork()

Oh - yeah, I didn't do anything with catching $SIG{CHLD} - There is the potential that you'll have zombie children until the parent process is done, but, once its done, they are gone too so I would worry about them too much unless the parent is a long, long running daemon.

Replies are listed 'Best First'.
(tye)Re: multiple fork()
by tye (Sage) on Apr 16, 2001 at 23:41 UTC

    Don't catch $SIG{CHLD} as each catch gives your program about a 1% chance of die'ing since Perl's signal handlers aren't safe. See "perldoc -f waitpid" for how to reap children without catching signals.

            - tye (but my friends call me "Tye")
      Says tye:
      each catch gives your program about a 1% chance of die'ing
      Is that number "1%" actually based in reality, or did you just make it up out of your head?

      Happy Bicycle Day!

      --
      Mark Dominus
      Perl Paraphernalia

        Both? It is from a vague memory of someone (Ilya?) running some tests before we realized why signal handlers weren't reliable. He found that the rate of failure for signal handlers was constant whether they did nothing or something.

        I don't have time to at the moment, but a search of Usenet might turn up the original research results.

        The start of this part of the thread makes me wonder if there is some operating system dependency that I don't understand or recent patches to improve the problem.

                - tye (but my friends call me "Tye")
      My bad. Catch may have been misleading. I generally do things like
      use POSIX (); $SIG{CHLD} = \&sig_chld; sub sig_chld { 1 while (waitpid(-1, POSIX::WNOHANG()) > 0); $SIG{CHLD} = \&sig_chld; }
      In my terminology, this is catching the SIG CHLD. I haven't had any trouble with this sort of setup under some extremely heavy loads.

        Then you have been lucky. It can fail.

                - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://72903]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-24 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found