alarm(2)

alarm2

Set an alarm clock for delivery of a signal

Usage

#include <unistd.h>

unsigned int alarm(unsigned int seconds);

Library

Standard C library (libc, -lc)

Overview

alarm() arranges for a SIGALRM signal to be delivered to the calling process in seconds seconds.

If seconds is zero, any pending alarm is canceled.

In any event any previously set alarm() is canceled.

Return value

alarm() returns the number of seconds remaining until any previously scheduled alarm was due to be delivered, or zero if there was no previously scheduled alarm.

Notes

alarm() and setitimer(2) share the same timer; calls to one will interfere with use of the other.

Alarms created by alarm() are preserved across execve(2) and are not inherited by children created via fork(2).

sleep(3) may be implemented using SIGALRM; mixing calls to alarm() and sleep(3) is a bad idea.

Scheduling delays can, as ever, cause the execution of the process to be delayed by an arbitrary amount of time.

Releases

19 releases since Debian 1.1 (Buzz); the text changed 15 times.

  1. 1.1–1.2
  2. 1.3–2.1
  3. 2.2
  4. 3.0
  5. 3.1
  6. 4.0
  7. 5.0
  8. 6.0
  9. 7
  10. 8
  11. 9
  12. 10
  13. 11
  14. 12
  15. 13
  16. Arch

Standards

POSIX.1-2024.

History

4.3BSD, SVr4, POSIX.1-1988.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.