Argel has asked for the wisdom of the Perl Monks concerning the following question:
eval.pl:
test.pl#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @return; eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required alarm 5; @return = `./test.pl`; alarm 0; }; if( $@ ) { # CASE: Command timed out die unless $@ eq "alarm\n"; # propagate unexpected errors } else { # CASE: Did *not* timeout } print Data::Dumper->Dump([\@return],['return']);
output#!/usr/bin/perl print "Foo\n"; sleep 2; print "Bar\n"; sleep 3; print "Foobar\n";
$return = [];
-- Argel
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Saving output when alarm goes off?
by BUU (Prior) on Dec 30, 2005 at 22:47 UTC |