Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Timeout on script

by Coruscate (Sexton)
on Jan 26, 2004 at 20:24 UTC ( [id://324259]=note: print w/replies, xml ) Need Help??


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
    The OP doesn't say one way or the other, but note that Abigail's kills the new process and Coruscate's does not.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://324259]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found