]>
Commit | Line | Data |
---|---|---|
bf5a7247 | 1 | .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de) |
fea681da | 2 | .\" |
5fbde956 | 3 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
c08df37a | 4 | .\" |
fea681da | 5 | .\" Modified Sat Jul 24 18:16:02 1993 by Rik Faith (faith@cs.unc.edu) |
1d767b55 | 6 | .TH SLEEP 3 2021-03-22 "GNU" "Linux Programmer's Manual" |
fea681da | 7 | .SH NAME |
1f6cc4a6 | 8 | sleep \- sleep for a specified number of seconds |
01ea535d AC |
9 | .SH LIBRARY |
10 | Standard C library | |
8fc3b2cf | 11 | .RI ( libc ", " \-lc ) |
fea681da MK |
12 | .SH SYNOPSIS |
13 | .nf | |
14 | .B #include <unistd.h> | |
68e4db0a | 15 | .PP |
fea681da MK |
16 | .BI "unsigned int sleep(unsigned int " "seconds" ); |
17 | .fi | |
18 | .SH DESCRIPTION | |
63aa9df0 | 19 | .BR sleep () |
5288e1f5 | 20 | causes the calling thread to sleep either until |
5272b4c4 | 21 | the number of real-time seconds specified in |
fea681da | 22 | .I seconds |
5288e1f5 | 23 | have elapsed or until a signal arrives which is not ignored. |
47297adb | 24 | .SH RETURN VALUE |
cfd4a9a6 MK |
25 | Zero if the requested time has elapsed, |
26 | or the number of seconds left to sleep, | |
27 | if the call was interrupted by a signal handler. | |
7e548ead ZL |
28 | .SH ATTRIBUTES |
29 | For an explanation of the terms used in this section, see | |
30 | .BR attributes (7). | |
c466875e MK |
31 | .ad l |
32 | .nh | |
7e548ead ZL |
33 | .TS |
34 | allbox; | |
c466875e | 35 | lbx lb lb |
7e548ead ZL |
36 | l l l. |
37 | Interface Attribute Value | |
38 | T{ | |
39 | .BR sleep () | |
40 | T} Thread safety MT-Unsafe sig:SIGCHLD/linux | |
41 | .TE | |
c466875e MK |
42 | .hy |
43 | .ad | |
847e0d88 | 44 | .sp 1 |
47297adb | 45 | .SH CONFORMING TO |
a6db971b | 46 | POSIX.1-2001, POSIX.1-2008. |
0d28787b | 47 | .SH NOTES |
330e8847 MK |
48 | On Linux, |
49 | .BR sleep () | |
50 | is implemented via | |
51 | .BR nanosleep (2). | |
52 | See the | |
53 | .BR nanosleep (2) | |
54 | man page for a discussion of the clock used. | |
0d28787b MK |
55 | .SS Portability notes |
56 | On some systems, | |
63aa9df0 | 57 | .BR sleep () |
fea681da | 58 | may be implemented using |
0d28787b MK |
59 | .BR alarm (2) |
60 | and | |
1ae6b2c7 | 61 | .B SIGALRM |
0d28787b | 62 | (POSIX.1 permits this); |
fea681da | 63 | mixing calls to |
bfbfd71d | 64 | .BR alarm (2) |
fea681da | 65 | and |
63aa9df0 | 66 | .BR sleep () |
fea681da MK |
67 | is a bad idea. |
68 | .PP | |
69 | Using | |
fb186734 | 70 | .BR longjmp (3) |
c13182ef | 71 | from a signal handler or modifying the handling of |
fea681da MK |
72 | .B SIGALRM |
73 | while sleeping will cause undefined results. | |
47297adb | 74 | .SH SEE ALSO |
9bfa6a84 | 75 | .BR sleep (1), |
fea681da | 76 | .BR alarm (2), |
87209bbe | 77 | .BR nanosleep (2), |
cfd4a9a6 MK |
78 | .BR signal (2), |
79 | .BR signal (7) |