$SIG{ALRM} =\&time_out; eval { alarm $time_out; @args = `$command 2>&1`; alarm (0); }; if ($@) { $err = 100; } # error codes from wait are bit shifted # if its 100, we timed out $err = ($? >> 8) if ($err != 100); sub time_out{ # Error: Timeout on process alarm 0; die; } return ({err => $err, data => \@args});