use strict; use warnings; use POSIX qw(:sys_wait_h); my $segfault=0; # set this to 188 to make perl segfault under 5.6.1 print $$,$/; $|++; my @pid; foreach my $i (0..3) { my $cmd='perl -le "print qq(hello world!); sleep ' .(10+$i*2) .(';' x $segfault ) .'; print qq(foo); " >NUL 2>&1'; print length($cmd),$/; $pid[$i]=system(1,$cmd); } my @wait=(0) x 4; my $c=0; while (grep !$_,@wait) { print(qq(running... @{[$c++]} [@wait]\r)); foreach my $i (0..3) { $wait[$i]||=waitpid($pid[$i],&WNOHANG); } sleep(1); } print(qq(Finished: @{[$c++]} [@wait]\r));