develooper Front page | perl.beginners | Postings from November 2002

RE: how do i make a script run for a certain period of time?

Thread Previous | Thread Next
November 27, 2002 11:40
RE: how do i make a script run for a certain period of time?
Message ID:
> -----Original Message-----
> From: david [] 
> Sent: Wednesday, November 27, 2002 8:34 PM
> To:
> Subject: RE: how do i make a script run for a certain period of time?
> Nyimi Jose wrote:
> > If you want your loop to first finish
> > what he is doing before die, do this instead.
> > Thus,when you receive the alarm sig you exit
> > first the loop then the script.
> > 
> > 
> > #!/usr/bin/perl -w
> > 
> > 
> you must be a bad bad guy!!! :-) just kidding!

Sorry !

> never listen to the perldoc hua? don't ever mix sleep and 
> alarm! on most platform, sleep is implemented using alarm 
> call. the problem? the 
> alarm call inside the sleep function will thus replace your 
> alarm function 
> just outside the while loop. check the perldoc -f alarm for more.

What about this ?:

use strict
my $time_to_die=0;
my $timeout=30; #in seconds

$SIG{ALRM} = sub { $time_to_die=1; };

#tasks here

> david
> -- 
> To unsubscribe, e-mail:
> For additional commands, e-mail:

**** DISCLAIMER ****

"This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at or refer to any Proximus agent.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About