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)
In reply to Re: Reaping Zombies
by jeffa
in thread Reaping Zombies
by dsb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |