|Syntactic Confectionery Delight|
Understanding fork + waitby jplindstrom (Monsignor)
|on Oct 29, 2002 at 13:11 UTC||Need Help??|
jplindstrom has asked for the
wisdom of the Perl Monks concerning the following question:
I wonder if someone could help me understand how fork and wait works. I may do the right thing, but I may also have missed something fundamental here.
Consider the following HTTP::Daemon code (simplified from my scenario), pretty much snipped from the synopsis, with forking added.
At first, the fork left zombies. So I Googled for that, and figured I need a wait() or IGNORE handler. So I added that. The zombies went away.
But, instead I got problems with a system() call. It failed and $! was "No child processes". Huh?
My guess is that now it's the child signal handler that's messing this up, so I reset it to 'DEFAULT' after the fork. This seems to solve the problem and the system() works fine again.
Is this correct? Or did I just manage to fix the symptom instead of the problem?