Right. Fix the real problem in the child, or just add a timeout:
# wait to reap all children
for my $pid (@child_pids)
{
local $SIG{__DIE__};
local $@ = "";
eval {
local $SIG{ALRM} = sub { die("alarm\n") };
alarm(3600);
# potentially long operation
waitpid $pid, 0;
alarm(0);
1;
} or do {
die($@) unless $@ eq "alarm\n";
# timed out
warn("Waited too long for child $pid. Skipping it.\n");
}
}