1sleep(3) Library Functions Manual sleep(3)
2
3
4
6 sleep - sleep for a specified number of seconds
7
9 Standard C library (libc, -lc)
10
12 #include <unistd.h>
13
14 unsigned int sleep(unsigned int seconds);
15
17 sleep() causes the calling thread to sleep either until the number of
18 real-time seconds specified in seconds have elapsed or until a signal
19 arrives which is not ignored.
20
22 Zero if the requested time has elapsed, or the number of seconds left
23 to sleep, if the call was interrupted by a signal handler.
24
26 For an explanation of the terms used in this section, see at‐
27 tributes(7).
28
29 ┌────────────────────────┬───────────────┬─────────────────────────────┐
30 │Interface │ Attribute │ Value │
31 ├────────────────────────┼───────────────┼─────────────────────────────┤
32 │sleep() │ Thread safety │ MT-Unsafe sig:SIGCHLD/linux │
33 └────────────────────────┴───────────────┴─────────────────────────────┘
34
36 On Linux, sleep() is implemented via nanosleep(2). See the
37 nanosleep(2) man page for a discussion of the clock used.
38
39 On some systems, sleep() may be implemented using alarm(2) and SIGALRM
40 (POSIX.1 permits this); mixing calls to alarm(2) and sleep() is a bad
41 idea.
42
44 POSIX.1-2008.
45
47 POSIX.1-2001.
48
50 Using longjmp(3) from a signal handler or modifying the handling of
51 SIGALRM while sleeping will cause undefined results.
52
54 sleep(1), alarm(2), nanosleep(2), signal(2), signal(7)
55
56
57
58Linux man-pages 6.04 2023-03-30 sleep(3)