in reply to Timeout on script
One that does not require the use of a fork:
#!c:/perl/bin/perl -w $|++; use strict; sleep $ARGV[0] and exit if $ARGV[0]; eval { local $SIG{ALRM} = sub { die "timeout\n" }; alarm 4; # change to timeout length system 'perl', $0, 6; # command to execute alarm 0; }; warn "external command timed out: $@\n" if $@ eq "timeout\n"; print "continuing on, regardless of success/failure\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Timeout on script
by ysth (Canon) on Jan 26, 2004 at 22:29 UTC |