ALARM(3)

NAME
alarm - schedule SIGALRM delivery

SYNOPSIS
#include <unistd.h>
unsigned int
alarm(unsigned int seconds);

DESCRIPTION
This is a simplified interface to setitimer(2).

The alarm() function schedules the SIGALRM signal for delivery to the calling process after the given number of seconds have elapsed.

If an alarm is already pending, another call to alarm() will supersede the prior call.

If seconds is zero, any pending alarm is cancelled.

RETURN VALUES
alarm() returns the number of seconds remaining until the pending alarm would have expired. If the alarm has already expired, the alarm was cancelled, or no alarm was ever scheduled, alarm() returns zero.

SEE ALSO
setitimer(2), sigaction(2), sigsuspend(2), signal(3), sleep(3), ualarm(3)

STANDARDS
The alarm() function conforms to p1003.1-2008.

HISTORY
An alarm() system call appeared in the Programmer's Workbench (PWB/UNIX) and was ported to AT&T UNIX. For 4.1cBSD, it was reimplemented as a wrapper around the setitimer(2) system call.

CAVEATS
The alarm() function is implemented with the per-process ITIMER_REAL timer described in setitimer(2). Use of both alarm() and setitimer(2) in the same program may yield confusing behavior.