in reply to Reaping Zombies (dont wanna wait)
The grandchild has no parent (child exits immediately), so it gets switched over to be a subprocess of init by the scheduler.unless (fork) { # this is the child unless (fork) { # this is the grandchild # Do your request processing here ... my $exec = "/usr/local/bin/monster -i$id $filePath$file &"; qx/$exec/; exit 0; } # end grandchild # Child process just exits. exit 0; } # Parent reaps quick-exiting child. wait;
The child exits immediately, so it doesn't need to wait for its child.
The parent waits for the child, so the zombie child is cleaned up right away.
You can add all the redo logic to this relatively easily; I've left it out so as to not obscure the simplicity of the mechanism. The mainline code does wait, but since the code it's waiting on runs extremely fast, it works more like relinquishing control to the child just long enough for it to exit.
As a funny aside, this is from the Perl 4 Programming Perl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Reaping Zombies (dont wanna wait)
by Anonymous Monk on Jun 11, 2003 at 18:53 UTC | |
by seaver (Pilgrim) on Jun 11, 2003 at 18:55 UTC | |
by pemungkah (Priest) on Jun 24, 2003 at 21:19 UTC | |
|
Re^2: Reaping Zombies (dont wanna wait)
by dragonchild (Archbishop) on Jul 09, 2004 at 15:48 UTC |