sub poll { # execute code with timeout eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required alarm 30; # alarm in 30 seconds # your code here (could timeout) alarm 0; # cancel alarm }; if ($@) { die $@ unless $@ eq "alarm\n"; # propagate unexpected errors # take action for timeout } }
In reply to Re: alarm() killing my program
by sflitman
in thread alarm() killing my program
by dimecadmium
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |