]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/usleep.3
ffix
[thirdparty/man-pages.git] / man3 / usleep.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\" 386BSD man pages
27 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified 2001-04-01 by aeb
29 .\" Modified 2003-07-23 by aeb
30 .\"
31 .TH USLEEP 3 2007-02-01 "" "Linux Programmer's Manual"
32 .SH NAME
33 usleep \- suspend execution for microsecond intervals
34 .SH SYNOPSIS
35 .nf
36 .B "#define _XOPEN_SOURCE 500 /* Or: #define _BSD_SOURCE */"
37 .br
38 .B "#include <unistd.h>"
39 .sp
40 .BI "int usleep(useconds_t " usec );
41 .fi
42 .SH DESCRIPTION
43 The
44 .BR usleep ()
45 function suspends execution of the calling process 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 0 on success, \-1 on error.
52 .SH ERRORS
53 .TP
54 .B EINTR
55 Interrupted by a signal.
56 .TP
57 .B EINVAL
58 \fIusec\fP is not smaller than 1000000.
59 (On systems where that is considered an error.)
60 .SH "CONFORMING TO"
61 4.3BSD, POSIX.1-2001.
62 POSIX.1-2001 declares this function obsolete; use
63 .BR nanosleep (2)
64 instead.
65
66 On the original BSD implementation,
67 and in glibc before version 2.2.2, the return type of this function is
68 .IR void .
69 The POSIX version returns
70 .IR int ,
71 and this is also the prototype used since glibc 2.2.2.
72
73 Only the
74 .B EINVAL
75 error return is documented by SUSv2.
76 .SH NOTES
77 The type
78 .B useconds_t
79 is an unsigned integer type capable of holding integers
80 in the range [0,1000000].
81 Programs will be more portable
82 if they never mention this type explicitly.
83 Use
84 .RS
85 .nf
86 .ta 8
87 .sp
88 #include <unistd.h>
89 \&...
90 unsigned int usecs;
91 \&.
92 usleep(usecs);
93 .fi
94 .RE
95 .LP
96 The interaction of this function with the
97 .B SIGALRM
98 signal, and with other timer functions such as
99 .BR alarm (2),
100 .BR sleep (3),
101 .BR nanosleep (2),
102 .BR setitimer (2),
103 .BR timer_create (3),
104 .BR timer_delete (3),
105 .BR timer_getoverrun (3),
106 .BR timer_gettime (3),
107 .BR timer_settime (3),
108 .BR ualarm (3)
109 is unspecified.
110 .SH "SEE ALSO"
111 .BR alarm (2),
112 .BR getitimer (2),
113 .BR nanosleep (2),
114 .BR select (2),
115 .BR setitimer (2),
116 .BR ualarm (3),
117 .BR sleep (3),
118 .BR feature_test_macros (7),
119 .BR time (7)