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 > > use strict > my $time_to_die=0; > my $sleep=5; #in seconds > my $timeout=3600; #in seconds > > $SIG{ALRM} = sub { $time_to_die=1; }; > > alarm($timeout); > while(!$time_to_die){ > #tasks here > sleep($sleep); > } > __END__ > you must be a bad bad guy!!! :-) just kidding! 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. davidThread Previous | Thread Next