Perl Programming/Keywords/alarm

Previous: accept Keywords Next: and

The alarm keywordEdit

alarm delivers a SIGALRM to this process after SECONDS wallclock seconds have passed. If SECONDS is omitted, contents of $_ are used. Some machines, however, may divert from the wallclock seconds by ±1 s.

This call starts one and only one timer; each new call disables the previous timer like a call with 0 would also do. From Perl 5.8.0 on, the timer with a better granularity is supplied by ualarm().

Instead of using alarm, it is possible to use Perl's four-argument version of select() with the first three arguments undefined. Another way is to use syscall() to access setitimer(2)(), if supported.

Beware of intermixing alarm and sleep calls, as sleep may be internally implemented on the system with alarmǃ


  alarm SECONDS


alarm 4;

See alsoEdit

Previous: accept Keywords Next: and