If you really don't care about the process returning just set
$SIG{CHLD} = 'IGNORE'
and ignore the issue of reaping all together. The other option is to do a NON blocking call to waitpid.
use POSIX qw(:sys_wait_h);
sub REAPER {
while ((my $pid = waitpid(-1,WNOHANG)) > 0) {
# do something with $pid;
}
$SIG{CHLD} = \&REAPER;
}
$SIG{CHLD} = \&REAPER;
Then you don't have to worry about your code blocking while waiting for children to return. However this doesn't mean you should do something like.
sub fork_bomb {
while (1){
fork_a_kid();
}
}
Speaking as a system administrator this won't earn you alot of good sysadmin karma. It is ok to fork many children just remember to limit the number of children on the system at any one time. Please read
perlipc and perlfork they helped me out big time.