]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/usleep.3
getent.1, intro.1, time.1, _exit.2, alloc_hugepages.2, arch_prctl.2, clock_getres...
[thirdparty/man-pages.git] / man3 / usleep.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 12.\"
fea681da
MK
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.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
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.\"
97986708 33.TH USLEEP 3 2016-03-15 "" "Linux Programmer's Manual"
fea681da
MK
34.SH NAME
35usleep \- suspend execution for microsecond intervals
36.SH SYNOPSIS
37.nf
fea681da 38.B "#include <unistd.h>"
68e4db0a 39.PP
c10859eb 40.BI "int usleep(useconds_t " usec );
fea681da 41.fi
68e4db0a 42.PP
cc4615cc
MK
43.in -4n
44Feature Test Macro Requirements for glibc (see
45.BR feature_test_macros (7)):
46.in
68e4db0a 47.PP
cc4615cc 48.BR usleep ():
2df50e3d
MK
49.ad l
50.RS 4
51.PD 0
52.TP 4
53Since glibc 2.12:
54.nf
6e0869f7
MK
55(_XOPEN_SOURCE\ >=\ 500) && ! (_POSIX_C_SOURCE\ >=\ 200809L)
56 || /* Glibc since 2.19: */ _DEFAULT_SOURCE
57 || /* Glibc versions <= 2.19: */ _BSD_SOURCE
2df50e3d
MK
58.TP 4
59.fi
60Before glibc 2.12:
cf7fa0a1
MK
61_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
62.\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
2df50e3d
MK
63.PD
64.RE
65.ad b
fea681da 66.SH DESCRIPTION
60a90ecd
MK
67The
68.BR usleep ()
ab1d9621 69function suspends execution of the calling thread for
c13182ef
MK
70(at least) \fIusec\fP microseconds.
71The sleep may be lengthened slightly
fea681da
MK
72by any system activity or by the time spent processing the call or by the
73granularity of system timers.
47297adb 74.SH RETURN VALUE
665637d4
MK
75The
76.BR usleep ()
77function returns 0 on success.
78On error, \-1 is returned, with
79.I errno
80set to indicate the cause of the error.
fea681da
MK
81.SH ERRORS
82.TP
097585ed 83.B EINTR
01538d0d
MK
84Interrupted by a signal; see
85.BR signal (7).
fea681da 86.TP
097585ed 87.B EINVAL
fea681da
MK
88\fIusec\fP is not smaller than 1000000.
89(On systems where that is considered an error.)
e0fc49a4 90.SH ATTRIBUTES
b4f53c94
PH
91For an explanation of the terms used in this section, see
92.BR attributes (7).
93.TS
94allbox;
95lb lb lb
96l l l.
97Interface Attribute Value
98T{
e0fc49a4 99.BR usleep ()
b4f53c94
PH
100T} Thread safety MT-Safe
101.TE
47297adb 102.SH CONFORMING TO
68e1685c 1034.3BSD, POSIX.1-2001.
5a7f195c
MK
104POSIX.1-2001 declares this function obsolete; use
105.BR nanosleep (2)
106instead.
f8eabcf9
MK
107POSIX.1-2008 removes the specification of
108.BR usleep ().
847e0d88 109.PP
c13182ef 110On the original BSD implementation,
5a7f195c
MK
111and in glibc before version 2.2.2, the return type of this function is
112.IR void .
c13182ef
MK
113The POSIX version returns
114.IR int ,
5a7f195c 115and this is also the prototype used since glibc 2.2.2.
847e0d88 116.PP
1274071a
MK
117Only the
118.B EINVAL
f041c2fd 119error return is documented by SUSv2 and POSIX.1-2001.
fea681da
MK
120.SH NOTES
121The type
f19a0f03 122.I useconds_t
fea681da 123is an unsigned integer type capable of holding integers
c13182ef
MK
124in the range [0,1000000].
125Programs will be more portable
126if they never mention this type explicitly.
127Use
bdd915e2 128.PP
a6e2f128 129.in +4n
bdd915e2 130.EX
fea681da
MK
131#include <unistd.h>
132\&...
5a7f195c 133 unsigned int usecs;
74d32233 134\&...
5a7f195c 135 usleep(usecs);
bdd915e2 136.EE
a6e2f128 137.in
dd3568a1 138.PP
8bd58774
MK
139The interaction of this function with the
140.B SIGALRM
141signal, and with other timer functions such as
cbe7b8d1 142.BR alarm (2),
fb186734
MK
143.BR sleep (3),
144.BR nanosleep (2),
145.BR setitimer (2),
804f03e6
MK
146.BR timer_create (2),
147.BR timer_delete (2),
148.BR timer_getoverrun (2),
149.BR timer_gettime (2),
150.BR timer_settime (2),
fb186734 151.BR ualarm (3)
fea681da 152is unspecified.
47297adb 153.SH SEE ALSO
bdd915e2 154BR alarm (2),
fea681da
MK
155.BR getitimer (2),
156.BR nanosleep (2),
157.BR select (2),
158.BR setitimer (2),
50e5322c 159.BR sleep (3),
f0c34053 160.BR ualarm (3),
5a7f195c 161.BR time (7)