1usleep(3) Library Functions Manual usleep(3)
2
3
4
6 usleep - suspend execution for microsecond intervals
7
9 Standard C library (libc, -lc)
10
12 #include <unistd.h>
13
14 int usleep(useconds_t usec);
15
16 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
17
18 usleep():
19 Since glibc 2.12:
20 (_XOPEN_SOURCE >= 500) && ! (_POSIX_C_SOURCE >= 200809L)
21 || /* glibc >= 2.19: */ _DEFAULT_SOURCE
22 || /* glibc <= 2.19: */ _BSD_SOURCE
23 Before glibc 2.12:
24 _BSD_SOURCE || _XOPEN_SOURCE >= 500
25
27 The usleep() function suspends execution of the calling thread for (at
28 least) usec microseconds. The sleep may be lengthened slightly by any
29 system activity or by the time spent processing the call or by the
30 granularity of system timers.
31
33 The usleep() function returns 0 on success. On error, -1 is returned,
34 with errno set to indicate the error.
35
37 EINTR Interrupted by a signal; see signal(7).
38
39 EINVAL usec is greater than or equal to 1000000. (On systems where
40 that is considered an error.)
41
43 For an explanation of the terms used in this section, see at‐
44 tributes(7).
45
46 ┌────────────────────────────────────────────┬───────────────┬─────────┐
47 │Interface │ Attribute │ Value │
48 ├────────────────────────────────────────────┼───────────────┼─────────┤
49 │usleep() │ Thread safety │ MT-Safe │
50 └────────────────────────────────────────────┴───────────────┴─────────┘
51
53 None.
54
56 4.3BSD, POSIX.1-2001. POSIX.1-2001 declares it obsolete, suggesting
57 nanosleep(2) instead. Removed in POSIX.1-2008.
58
59 On the original BSD implementation, and before glibc 2.2.2, the return
60 type of this function is void. The POSIX version returns int, and this
61 is also the prototype used since glibc 2.2.2.
62
63 Only the EINVAL error return is documented by SUSv2 and POSIX.1-2001.
64
66 The interaction of this function with the SIGALRM signal, and with oth‐
67 er timer functions such as alarm(2), sleep(3), nanosleep(2),
68 setitimer(2), timer_create(2), timer_delete(2), timer_getoverrun(2),
69 timer_gettime(2), timer_settime(2), ualarm(3) is unspecified.
70
72 alarm(2), getitimer(2), nanosleep(2), select(2), setitimer(2),
73 sleep(3), ualarm(3), useconds_t(3type), time(7)
74
75
76
77Linux man-pages 6.04 2023-03-30 usleep(3)