sub REAPER { {} until ( waitpid(-1, WNOHANG) == -1) }
since waitpid returns the PID of the deceased process, or -1 if there are no more child processes. See waitpid.
Your waitpid call will not return -1 since there's the monitor process hanging around. So waitpid will collect the PID of the child, but then loop forever. If you kill the monitor process, you'll see that your parent returns to its socket to listen. Change your handler to
sub REAPER { 1 until ( waitpid(-1, WNOHANG) > 0) }
and all should be fine. (1 is enough since constructing a hashref each time through the loop doesn't make much sense).
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: Socket Hangs Revisited
by shmem
in thread Socket Hangs Revisited
by mungohill
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |