sub executeTimed{ my $cmd = shift; $|++; my @results :shared; my $pid :shared; async { $pid = open my $fh, "$cmd |" or die "$!, $^E"; @results = <$fh>; }->detach; select(undef, undef, undef, 0.08); my $test = kill (0, $pid); if($test){ kill (3, $pid); push(@results, "Function timed out."); } return pop(@results); }