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.
(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")
| [reply] |
|
| [reply] |
|
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")
| [reply] |
|
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. | [reply] [d/l] |
|
| [reply] |
|
|
|
|