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