mount_setattr.2: Minor tweaks to Christian's patch
[man-pages.git] / man3 / usleep.3
blob358d6d36eb068c804f9b39dee7a585a5cc8d04af
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
30 .\" Modified 2001-04-01 by aeb
31 .\" Modified 2003-07-23 by aeb
32 .\"
33 .TH USLEEP 3  2021-03-22 "" "Linux Programmer's Manual"
34 .SH NAME
35 usleep \- suspend execution for microsecond intervals
36 .SH SYNOPSIS
37 .nf
38 .B "#include <unistd.h>"
39 .PP
40 .BI "int usleep(useconds_t " usec );
41 .fi
42 .PP
43 .RS -4
44 Feature Test Macro Requirements for glibc (see
45 .BR feature_test_macros (7)):
46 .RE
47 .PP
48 .BR usleep ():
49 .nf
50     Since glibc 2.12:
51         (_XOPEN_SOURCE >= 500) && ! (_POSIX_C_SOURCE >= 200809L)
52             || /* Glibc since 2.19: */ _DEFAULT_SOURCE
53             || /* Glibc <= 2.19: */ _BSD_SOURCE
54     Before glibc 2.12:
55         _BSD_SOURCE || _XOPEN_SOURCE >= 500
56 .\"    || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
57 .fi
58 .SH DESCRIPTION
59 The
60 .BR usleep ()
61 function suspends execution of the calling thread for
62 (at least) \fIusec\fP microseconds.
63 The sleep may be lengthened slightly
64 by any system activity or by the time spent processing the call or by the
65 granularity of system timers.
66 .SH RETURN VALUE
67 The
68 .BR usleep ()
69 function returns 0 on success.
70 On error, \-1 is returned, with
71 .I errno
72 set to indicate the error.
73 .SH ERRORS
74 .TP
75 .B EINTR
76 Interrupted by a signal; see
77 .BR signal (7).
78 .TP
79 .B EINVAL
80 \fIusec\fP is greater than or equal to 1000000.
81 (On systems where that is considered an error.)
82 .SH ATTRIBUTES
83 For an explanation of the terms used in this section, see
84 .BR attributes (7).
85 .ad l
86 .nh
87 .TS
88 allbox;
89 lbx lb lb
90 l l l.
91 Interface       Attribute       Value
93 .BR usleep ()
94 T}      Thread safety   MT-Safe
95 .TE
96 .hy
97 .ad
98 .sp 1
99 .SH CONFORMING TO
100 4.3BSD, POSIX.1-2001.
101 POSIX.1-2001 declares this function obsolete; use
102 .BR nanosleep (2)
103 instead.
104 POSIX.1-2008 removes the specification of
105 .BR usleep ().
107 On the original BSD implementation,
108 and in glibc before version 2.2.2, the return type of this function is
109 .IR void .
110 The POSIX version returns
111 .IR int ,
112 and this is also the prototype used since glibc 2.2.2.
114 Only the
115 .B EINVAL
116 error return is documented by SUSv2 and POSIX.1-2001.
117 .SH NOTES
118 The type
119 .I useconds_t
120 is an unsigned integer type capable of holding integers
121 in the range [0,1000000].
122 Programs will be more portable
123 if they never mention this type explicitly.
126 .in +4n
128 #include <unistd.h>
129 \&...
130     unsigned int usecs;
131 \&...
132     usleep(usecs);
136 The interaction of this function with the
137 .B SIGALRM
138 signal, and with other timer functions such as
139 .BR alarm (2),
140 .BR sleep (3),
141 .BR nanosleep (2),
142 .BR setitimer (2),
143 .BR timer_create (2),
144 .BR timer_delete (2),
145 .BR timer_getoverrun (2),
146 .BR timer_gettime (2),
147 .BR timer_settime (2),
148 .BR ualarm (3)
149 is unspecified.
150 .SH SEE ALSO
151 .BR alarm (2),
152 .BR getitimer (2),
153 .BR nanosleep (2),
154 .BR select (2),
155 .BR setitimer (2),
156 .BR sleep (3),
157 .BR ualarm (3),
158 .BR time (7)