in reply to Reaping Zombies
It has been several years since i looked at this stuff. First, i recommend you have a look at Advanced Programming in the Unix Environment. It's in C, but the concepts apply to Perl as well. Having said that, back in 2002 i had to write a forking server. This is the reaper code that i came up with:
Very simple, simply keep reaping children and store their status in a hash so that the server which did the forking can return the status to the client.use POSIX qw(WNOHANG); our (%PID); sub reaper { while ((my $kid = waitpid(-1,WNOHANG)) > 0 ) { warn "Reaped child with PID $kid"; my $status = $? >> 8; $PID{$kid} = $status; } }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reaping Zombies
by dsb (Chaplain) on Feb 15, 2006 at 19:00 UTC | |
by salva (Canon) on Feb 15, 2006 at 19:23 UTC | |
by ikegami (Patriarch) on Feb 15, 2006 at 19:36 UTC | |
by dsb (Chaplain) on Feb 15, 2006 at 19:33 UTC | |
by salva (Canon) on Feb 15, 2006 at 19:35 UTC |