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