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