]>
Commit | Line | Data |
---|---|---|
fea681da MK |
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. | |
c13182ef | 11 | .\" |
fea681da MK |
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. | |
c13182ef | 19 | .\" |
fea681da MK |
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 | .\" | |
5a7f195c | 31 | .TH USLEEP 3 2007-02-01 "" "Linux Programmer's Manual" |
fea681da MK |
32 | .SH NAME |
33 | usleep \- suspend execution for microsecond intervals | |
34 | .SH SYNOPSIS | |
35 | .nf | |
5a7f195c | 36 | .B "#define _XOPEN_SOURCE 500 /* Or: #define _BSD_SOURCE */" |
fea681da MK |
37 | .br |
38 | .B "#include <unistd.h>" | |
39 | .sp | |
c10859eb | 40 | .BI "int usleep(useconds_t " usec ); |
fea681da MK |
41 | .fi |
42 | .SH DESCRIPTION | |
60a90ecd MK |
43 | The |
44 | .BR usleep () | |
45 | function suspends execution of the calling process for | |
c13182ef MK |
46 | (at least) \fIusec\fP microseconds. |
47 | The sleep may be lengthened slightly | |
fea681da MK |
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" | |
5a7f195c | 51 | 0 on success, \-1 on error. |
fea681da MK |
52 | .SH ERRORS |
53 | .TP | |
54 | EINTR | |
55 | Interrupted by a signal. | |
56 | .TP | |
57 | EINVAL | |
58 | \fIusec\fP is not smaller than 1000000. | |
59 | (On systems where that is considered an error.) | |
60 | .SH "CONFORMING TO" | |
68e1685c | 61 | 4.3BSD, POSIX.1-2001. |
5a7f195c MK |
62 | POSIX.1-2001 declares this function obsolete; use |
63 | .BR nanosleep (2) | |
64 | instead. | |
65 | ||
c13182ef | 66 | On the original BSD implementation, |
5a7f195c MK |
67 | and in glibc before version 2.2.2, the return type of this function is |
68 | .IR void . | |
c13182ef MK |
69 | The POSIX version returns |
70 | .IR int , | |
5a7f195c MK |
71 | and this is also the prototype used since glibc 2.2.2. |
72 | ||
fea681da MK |
73 | Only the EINVAL error return is documented by SUSv2. |
74 | .SH NOTES | |
75 | The type | |
76 | .B useconds_t | |
77 | is an unsigned integer type capable of holding integers | |
c13182ef MK |
78 | in the range [0,1000000]. |
79 | Programs will be more portable | |
80 | if they never mention this type explicitly. | |
81 | Use | |
fea681da MK |
82 | .RS |
83 | .nf | |
84 | .ta 8 | |
85 | .sp | |
86 | #include <unistd.h> | |
87 | \&... | |
5a7f195c | 88 | unsigned int usecs; |
c13182ef | 89 | \&. |
5a7f195c | 90 | usleep(usecs); |
fea681da MK |
91 | .fi |
92 | .RE | |
fea681da | 93 | .LP |
8bd58774 MK |
94 | The interaction of this function with the |
95 | .B SIGALRM | |
96 | signal, and with other timer functions such as | |
cbe7b8d1 | 97 | .BR alarm (2), |
fb186734 MK |
98 | .BR sleep (3), |
99 | .BR nanosleep (2), | |
100 | .BR setitimer (2), | |
101 | .BR timer_create (3), | |
102 | .BR timer_delete (3), | |
103 | .BR timer_getoverrun (3), | |
104 | .BR timer_gettime (3), | |
105 | .BR timer_settime (3), | |
106 | .BR ualarm (3) | |
fea681da | 107 | is unspecified. |
fea681da MK |
108 | .SH "SEE ALSO" |
109 | .BR alarm (2), | |
110 | .BR getitimer (2), | |
111 | .BR nanosleep (2), | |
112 | .BR select (2), | |
113 | .BR setitimer (2), | |
5a7f195c | 114 | .BR ualarm (3), |
50e5322c | 115 | .BR sleep (3), |
5a7f195c MK |
116 | .BR feature_test_macros (7), |
117 | .BR time (7) |