| 1 |
'\" t |
| 2 |
.\" Copyright 1993, Thomas Koenig <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH sleep 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
sleep \- sleep for a specified number of seconds |
| 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 sleep(unsigned int " "seconds" ); |
| 18 |
.fi |
| 19 |
.SH DESCRIPTION |
| 20 |
.BR sleep () |
| 21 |
causes the calling thread to sleep either until |
| 22 |
the number of real-time seconds specified in |
| 23 |
.I seconds |
| 24 |
have elapsed or until a signal arrives which is not ignored. |
| 25 |
.SH RETURN VALUE |
| 26 |
Zero if the requested time has elapsed, |
| 27 |
or the number of seconds left to sleep, |
| 28 |
if the call was interrupted by a signal handler. |
| 29 |
.SH ATTRIBUTES |
| 30 |
For an explanation of the terms used in this section, see |
| 31 |
.BR attributes (7). |
| 32 |
.TS |
| 33 |
allbox; |
| 34 |
lbx lb lb |
| 35 |
l l l. |
| 36 |
Interface Attribute Value |
| 37 |
T{ |
| 38 |
.na |
| 39 |
.nh |
| 40 |
.BR sleep () |
| 41 |
T} Thread safety MT-Unsafe sig:SIGCHLD/linux |
| 42 |
.TE |
| 43 |
.SH VERSIONS |
| 44 |
On Linux, |
| 45 |
.BR sleep () |
| 46 |
is implemented via |
| 47 |
.BR nanosleep (2). |
| 48 |
See the |
| 49 |
.BR nanosleep (2) |
| 50 |
man page for a discussion of the clock used. |
| 51 |
.P |
| 52 |
On some systems, |
| 53 |
.BR sleep () |
| 54 |
may be implemented using |
| 55 |
.BR alarm (2) |
| 56 |
and |
| 57 |
.B SIGALRM |
| 58 |
(POSIX.1 permits this); |
| 59 |
mixing calls to |
| 60 |
.BR alarm (2) |
| 61 |
and |
| 62 |
.BR sleep () |
| 63 |
is a bad idea. |
| 64 |
.SH STANDARDS |
| 65 |
POSIX.1-2008. |
| 66 |
.SH HISTORY |
| 67 |
POSIX.1-2001. |
| 68 |
.SH CAVEATS |
| 69 |
Using |
| 70 |
.BR longjmp (3) |
| 71 |
from a signal handler or modifying the handling of |
| 72 |
.B SIGALRM |
| 73 |
while sleeping will cause undefined results. |
| 74 |
.SH SEE ALSO |
| 75 |
.BR sleep (1), |
| 76 |
.BR alarm (2), |
| 77 |
.BR nanosleep (2), |
| 78 |
.BR signal (2), |
| 79 |
.BR signal (7) |