Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: CountDownTimer for my perl program,

by vinoth.ree (Parson)
on Feb 22, 2013 at 07:21 UTC ( #1020089=note: print w/ replies, xml ) Need Help??


in reply to CountDownTimer for my perl program,

tmharish ++

Here is the exact code to timeout for 25 minutes.

use strict; use warnings; use utf8; eval { local %SIG; $SIG{ALRM}= sub{ die "timeout reached, after 25 minutes!\n"; }; alarm 25*60; # 25 minutes. while(1) { sleep(1); print "Hello Perl\n"; } alarm 0; }; alarm 0; if($@) { print "Error: $@\n"; } exit(0);


Comment on Re: CountDownTimer for my perl program,
Download Code
Re^2: CountDownTimer for my perl program,
by MidLifeXis (Prior) on Feb 22, 2013 at 13:52 UTC

    See the warning about using sleep and alarm being used in tandem.

    --MidLifeXis

Re^2: CountDownTimer for my perl program,
by vinoth.ree (Parson) on Feb 25, 2013 at 04:46 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2014-09-20 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (158 votes), past polls