-.\" $OpenBSD: alarm.3,v 1.15 2016/01/28 22:11:39 jmc Exp $
+.\" $OpenBSD: alarm.3,v 1.16 2021/06/18 22:21:29 cheloha Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: January 28 2016 $
+.Dd $Mdocdate: June 18 2021 $
.Dt ALARM 3
.Os
.Sh NAME
.Nm alarm
-.Nd set signal timer alarm
+.Nd schedule SIGALRM delivery
.Sh SYNOPSIS
.In unistd.h
.Ft unsigned int
.Pp
The
.Fn alarm
-function waits a count of
-.Ar seconds
-before asserting the terminating signal
-.Dv SIGALRM .
-When the signal has successfully been caught,
-.Fn alarm
-returns the amount of time left on the clock.
-The maximum number of
-.Ar seconds
-allowed
-is 100000000.
+function schedules the
+.Dv SIGALRM
+signal for delivery to the calling process after the given number of
+.Fa seconds
+have elapsed.
.Pp
-If an alarm has been set with
-.Fn alarm ,
+If an alarm is already pending,
another call to
.Fn alarm
will supersede the prior call.
-The request
-.Fn alarm "0"
-voids the current
-alarm.
+.Pp
+If
+.Fa seconds
+is zero,
+any pending alarm is cancelled.
.Sh RETURN VALUES
-If the call succeeds, any time left remaining from a previous call is returned.
-If an error occurs, the value \-1 is returned, and a more precise
-error code is placed in the global variable
-.Va errno .
+.Fn 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,
+.Fn alarm
+returns zero.
.Sh SEE ALSO
.Xr setitimer 2 ,
.Xr sigaction 2 ,
it was reimplemented as a wrapper around the
.Xr setitimer 2
system call.
+.Sh CAVEATS
+The
+.Fn alarm
+function is implemented with the per-process
+.Dv ITIMER_REAL
+timer described in
+.Xr setitimer 2 .
+Use of both
+.Fn alarm
+and
+.Xr setitimer 2
+in the same program may yield confusing behavior.