Problems? Is your data what you think it is? | |
PerlMonks |
perlfunc:alarmby gods (Initiate) |
on Aug 24, 1999 at 22:41 UTC ( [id://175]=perlfunc: print w/replies, xml ) | Need Help?? |
alarmSee the current Perl documentation for alarm. Here is our local, out-dated (pre-5.6) version: alarm - schedule a SIGALRM
alarm SECONDS alarm
Arranges to have a
SIGALRM delivered to this process after the specified number of seconds have elapsed. If
SECONDS is not specified, the value stored in
For delays of finer granularity than one second, you may use Perl's
syscall() interface to access
If you want to use alarm() to time out a system call you need to use an
eval()/die() pair. You can't rely on the alarm causing the system call to fail with
eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required alarm $timeout; $nread = sysread SOCKET, $buffer, $size; alarm 0; }; if ($@) { die unless $@ eq "alarm\n"; # propagate unexpected errors # timed out } else { # didn't } |
|