Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: CountDownTimer for my perl program,

by vinoth.ree (Prior)
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
Replies are listed 'Best First'.
Re^2: CountDownTimer for my perl program,
by MidLifeXis (Monsignor) 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 (Prior) 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 pondering the Monastery: (7)
As of 2015-07-31 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls