in reply to Re: wait_all_children for Proc::Fork?
in thread wait_all_children for Proc::Fork?

At the risk of identifying a problem without proposing a solution, the above would work until one of the children hangs - causing the parent to hang.

A user level that continues to overstate my experience :-))
  • Comment on Re^2: wait_all_children for Proc::Fork?

Replies are listed 'Best First'.
Re^3: wait_all_children for Proc::Fork?
by repellent (Priest) on Jun 10, 2009 at 17:22 UTC
    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"); } }