Waiting on a child process in perl
问题 I am having an issue with capturing the return status of the child process. below is a simplified version of my code. use Modern::Perl; use POSIX; use AnyEvent; my @jobs = (1, 7, 3, 9 , 4 , 2); my %pid; my %running; my $t = AE::timer 0, 5, sub{ while(scalar( keys %running < 3) && scalar (@jobs)){ my $job = shift @jobs; $running{$job}=1; $pid{$job} = run($job); } for(keys %running){ delete $running{$_} unless check($pid{$_},$_); } exit unless scalar keys %running; }; AnyEvent->condvar->recv;