mattski has asked for the wisdom of the Perl Monks concerning the following question:
my $err; my @output; eval { local $SIG{ALRM} = sub { die "alarm\n" }; alert 10; my $pid = open(PIPE,"-|") or die "Error: $!"; exec @command_array or die "Error: $!"; while(<PIPE>) { push(@output,$_); } close PIPE; if(kill('TERM',$pid)) { warn "Killed PID $pid\n"; } }; alarm 0; if($@ && $@ ne "alarm\n") { $err = "Non-timeout error: $@"; push(@output,$err); } else { $err = "Timeout error: $@"; push(@output,$err); }
|
|---|