NAME
alarm — schedule
an alarm signal
SYNOPSIS
#include <unistd.h> unsigned int alarm(unsigned int seconds);
DESCRIPTION
The alarm() function causes the system to generate a SIGALRM signal for the process after the number of real-time seconds specified by seconds have elapsed. Processor scheduling delays may prevent the process from handling the signal as soon as it is generated.
If seconds is 0, a pending alarm request, if any, is cancelled.
Alarm requests are not stacked; only one SIGALRM generation can be scheduled in this manner; if the SIGALRM signal has not yet been generated, the call will result in rescheduling the time at which the SIGALRM signal will be generated.
Interactions between alarm() and any of setitimer(), ualarm() or usleep() are unspecified.
RETURN VALUE
If there is a previous alarm() request with time remaining, alarm() returns a non-zero value that is the number of seconds until the previous request would have generated a SIGALRM signal. Otherwise, alarm() returns 0.
ERRORS
The alarm() function is always successful, and no return value is reserved to indicate an error.
EXAMPLES
None.
APPLICATION USAGE
The fork(3) function clears pending alarms in the child process. A new process image created by one of the exec functions inherits the time left to an alarm signal in the old process' image.
FUTURE DIRECTIONS
None.
SEE ALSO
exec(3) , fork(3) , getitimer(3) , pause(3) , sigaction(3) , ualarm(3) , usleep(3) , <signal.h> , <unistd.h> .
DERIVATION
Derived from Issue 1 of the SVID.