Debian Codegraph @

upstream/debian-unstable/man2/alarm.2

raw
1 .\" Copyright 1992, Drew Eckhardt <[email protected]>
2 .\" Copyright 1993, Ian Jackson <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH alarm 2 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 alarm \- set an alarm clock for delivery of a signal
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <unistd.h>
16 .P
17 .BI "unsigned int alarm(unsigned int " seconds );
18 .fi
19 .SH DESCRIPTION
20 .BR alarm ()
21 arranges for a
22 .B SIGALRM
23 signal to be delivered to the calling process in
24 .I seconds
25 seconds.
26 .P
27 If
28 .I seconds
29 is zero, any pending alarm is canceled.
30 .P
31 In any event any previously set
32 .BR alarm ()
33 is canceled.
34 .SH RETURN VALUE
35 .BR alarm ()
36 returns the number of seconds remaining until any previously scheduled
37 alarm was due to be delivered, or zero if there was no previously
38 scheduled alarm.
39 .SH STANDARDS
40 POSIX.1-2024.
41 .SH HISTORY
42 4.3BSD,
43 SVr4,
44 POSIX.1-1988.
45 .SH NOTES
46 .BR alarm ()
47 and
48 .BR setitimer (2)
49 share the same timer;
50 calls to one will interfere with use of the other.
51 .P
52 Alarms created by
53 .BR alarm ()
54 are preserved across
55 .BR execve (2)
56 and are not inherited by children created via
57 .BR fork (2).
58 .P
59 .BR sleep (3)
60 may be implemented using
61 .BR SIGALRM ;
62 mixing calls to
63 .BR alarm ()
64 and
65 .BR sleep (3)
66 is a bad idea.
67 .P
68 Scheduling delays can, as ever, cause the execution of the process to
69 be delayed by an arbitrary amount of time.
70 .SH SEE ALSO
71 .BR gettimeofday (2),
72 .BR pause (2),
73 .BR select (2),
74 .BR setitimer (2),
75 .BR sigaction (2),
76 .BR signal (2),
77 .BR timer_create (2),
78 .BR timerfd_create (2),
79 .BR sleep (3),
80 .BR time (7)