in reply to Kill a command launched within script
local $SIG {ALRM} = sub {die "alarm"}; my $fh; eval { alarm (2); open $fh, "-|", "$vmdiscover ..." or die "Couldn't open $vmdiscove +r: $!"; while (<$fh>) {}; alarm (0); }; if ($@ && $@ =~ /^alarm/) { print "Command has timed out"; } elsif ($@) { print "$@\n"; } close $fh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Kill a command launched within script
by massa (Hermit) on Nov 21, 2008 at 18:17 UTC |