]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/usleep.3
Automated unformatting of parentheses using unformat_parens.sh
[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 2003-07-23 "" "Linux Programmer's Manual"
32 .SH NAME
33 usleep \- suspend execution for microsecond intervals
34 .SH SYNOPSIS
35 .nf
36 /* BSD version */
37 .B "#include <unistd.h>"
38 .sp
39 .BI "void usleep(unsigned long " usec );
40 .sp
41 /* SUSv2 version */
42 .B "#define _XOPEN_SOURCE 500"
43 .br
44 .B "#include <unistd.h>"
45 .sp
46 .BI "int usleep(useconds_t " usec ");
47 .fi
48 .SH DESCRIPTION
49 The \fBusleep\fP() function suspends execution of the calling process for
50 (at least) \fIusec\fP microseconds. The sleep may be lengthened slightly
51 by any system activity or by the time spent processing the call or by the
52 granularity of system timers.
53 .SH "RETURN VALUE"
54 None (BSD). Or: 0 on success, \-1 on error (SUSv2).
55 .SH ERRORS
56 .TP
57 EINTR
58 Interrupted by a signal.
59 .TP
60 EINVAL
61 \fIusec\fP is not smaller than 1000000.
62 (On systems where that is considered an error.)
63 .SH "CONFORMING TO"
64 4.3BSD.
65 The SUSv2 version returns int, and this is also the prototype
66 used by glibc 2.2.2.
67 Only the EINVAL error return is documented by SUSv2.
68 .SH NOTES
69 The type
70 .B useconds_t
71 is an unsigned integer type capable of holding integers
72 in the range [0,1000000]. Programs will be more portable
73 if they never mention this type explicitly. Use
74 .RS
75 .nf
76 .ta 8
77 .sp
78 #include <unistd.h>
79 \&...
80 unsigned int usecs;
81 \&...
82 usleep(usecs);
83 .sp
84 .fi
85 .RE
86 This type is defined by
87 .I <sys/types.h>
88 included by
89 .I <unistd.h>
90 but glibc defines it only when _XOPEN_SOURCE has a value not less than 500,
91 or both _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED are defined.
92 .\" useconds_t also gives problems on HPUX 10.
93 .LP
94 The interaction of this function with the SIGALRM signal, and with
95 other timer functions such as
96 .IR alarm (),
97 .IR sleep (),
98 .IR nanosleep (),
99 .IR setitimer (),
100 .IR timer_create (),
101 .IR timer_delete (),
102 .IR timer_getoverrun (),
103 .IR timer_gettime (),
104 .IR timer_settime (),
105 .IR ualarm ()
106 is unspecified.
107 .LP
108 This function is obsolete. Use
109 .BR nanosleep (2)
110 or
111 .BR setitimer (2)
112 instead.
113 .SH "SEE ALSO"
114 .BR alarm (2),
115 .BR getitimer (2),
116 .BR nanosleep (2),
117 .BR select (2),
118 .BR setitimer (2),
119 .BR sleep (3)