OpenBSD manual page server

Manual Page Search Parameters

ALARM(3) Library Functions Manual ALARM(3)

alarmschedule SIGALRM delivery

#include <unistd.h>

unsigned int
alarm(unsigned int seconds);

This is a simplified interface to setitimer(2).

The () 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 () will supersede the prior call.

If seconds is zero, any pending alarm is cancelled.

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.

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

The alarm() function conforms to IEEE Std 1003.1-2008 (“POSIX.1”).

An alarm() system call first appeared outside of Bell Labs in the “50 changes” tape for Version 6 AT&T UNIX. It was first officially released with PWB/UNIX 1.0. For 4.1cBSD, it was reimplemented as a wrapper around the setitimer(2) system call.

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.

August 2, 2022 OpenBSD-current