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";
In reply to Re: Timeout on script
by Coruscate
in thread Timeout on script
by hotshot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |