share/mk/: Fix includes
[man-pages.git] / man3 / usleep.3
blobc0715c20700a9e85c5377c848ad666fce410f107
1 '\" t
2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" References consulted:
7 .\"     Linux libc source code
8 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
9 .\"     386BSD man pages
10 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
11 .\" Modified 2001-04-01 by aeb
12 .\" Modified 2003-07-23 by aeb
13 .\"
14 .TH usleep 3 (date) "Linux man-pages (unreleased)"
15 .SH NAME
16 usleep \- suspend execution for microsecond intervals
17 .SH LIBRARY
18 Standard C library
19 .RI ( libc ", " \-lc )
20 .SH SYNOPSIS
21 .nf
22 .B "#include <unistd.h>"
24 .BI "int usleep(useconds_t " usec );
25 .fi
27 .RS -4
28 Feature Test Macro Requirements for glibc (see
29 .BR feature_test_macros (7)):
30 .RE
32 .BR usleep ():
33 .nf
34     Since glibc 2.12:
35         (_XOPEN_SOURCE >= 500) && ! (_POSIX_C_SOURCE >= 200809L)
36             || /* glibc >= 2.19: */ _DEFAULT_SOURCE
37             || /* glibc <= 2.19: */ _BSD_SOURCE
38     Before glibc 2.12:
39         _BSD_SOURCE || _XOPEN_SOURCE >= 500
40 .\"    || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
41 .fi
42 .SH DESCRIPTION
43 The
44 .BR usleep ()
45 function suspends execution of the calling thread for
46 (at least) \fIusec\fP microseconds.
47 The sleep may be lengthened slightly
48 by any system activity or by the time spent processing the call or by the
49 granularity of system timers.
50 .SH RETURN VALUE
51 The
52 .BR usleep ()
53 function returns 0 on success.
54 On error, \-1 is returned, with
55 .I errno
56 set to indicate the error.
57 .SH ERRORS
58 .TP
59 .B EINTR
60 Interrupted by a signal; see
61 .BR signal (7).
62 .TP
63 .B EINVAL
64 \fIusec\fP is greater than or equal to 1000000.
65 (On systems where that is considered an error.)
66 .SH ATTRIBUTES
67 For an explanation of the terms used in this section, see
68 .BR attributes (7).
69 .TS
70 allbox;
71 lbx lb lb
72 l l l.
73 Interface       Attribute       Value
75 .na
76 .nh
77 .BR usleep ()
78 T}      Thread safety   MT-Safe
79 .TE
80 .SH STANDARDS
81 None.
82 .SH HISTORY
83 4.3BSD, POSIX.1-2001.
84 POSIX.1-2001 declares it obsolete, suggesting
85 .BR nanosleep (2)
86 instead.
87 Removed in POSIX.1-2008.
89 On the original BSD implementation,
90 and before glibc 2.2.2, the return type of this function is
91 .IR void .
92 The POSIX version returns
93 .IR int ,
94 and this is also the prototype used since glibc 2.2.2.
96 Only the
97 .B EINVAL
98 error return is documented by SUSv2 and POSIX.1-2001.
99 .SH CAVEATS
100 The interaction of this function with the
101 .B SIGALRM
102 signal, and with other timer functions such as
103 .BR alarm (2),
104 .BR sleep (3),
105 .BR nanosleep (2),
106 .BR setitimer (2),
107 .BR timer_create (2),
108 .BR timer_delete (2),
109 .BR timer_getoverrun (2),
110 .BR timer_gettime (2),
111 .BR timer_settime (2),
112 .BR ualarm (3)
113 is unspecified.
114 .SH SEE ALSO
115 .BR alarm (2),
116 .BR getitimer (2),
117 .BR nanosleep (2),
118 .BR select (2),
119 .BR setitimer (2),
120 .BR sleep (3),
121 .BR ualarm (3),
122 .BR useconds_t (3type),
123 .BR time (7)