.TH alarm() "" "" "System Call (libc)"
.PC "Set a timer"
.B "#include <unistd.h>"
\fBalarm(\fIseconds\^\fB)\fR
\fBunsigned \fIseconds\^\fB;\fR
.PP
.B alarm()
sets a timer.
After
.IR seconds, 
the \*(CO kernel sends signal
.B SIGALRM
to the process that invoked
.BR alarm() .
Setting
.I seconds
to zero turns off the alarm timer.
.PP
By default, signal
.B SIGALRM
terminates the process.
However, a program can invoke the system call
.B signal()
to catch this signal, or ignore it.
Because of scheduling variation
and the one-second granularity, the action of
.B alarm()
is predictable only to within one second.
.PP
.B alarm()
is useful for such things as timeouts.
For example,
a process on a dial-in port might hang up the line after
a sufficient time has elapsed with no user response.
.PP
.B alarm()
returns the previous alarm value,
which represents the time remaining from the previous call.
Time remaining is superseded by the new alarm value.
.SH "See Also"
.Xr libc, libc
.Xr signal(), signal
.Xr sleep(), sleep
.Xr unistd.h unistd.h
.br
\*(PX Standard, \(sc3.4.1
.SH Notes
A process can set only one alarm at a time.
