1USLEEP(3) Linux Programmer's Manual USLEEP(3)
2
3
4
6 usleep - suspend execution for microsecond intervals
7
9 #define _XOPEN_SOURCE 500 /* Or: #define _BSD_SOURCE */
10 #include <unistd.h>
11
12 int usleep(useconds_t usec);
13
15 The usleep() function suspends execution of the calling process for (at
16 least) usec microseconds. The sleep may be lengthened slightly by any
17 system activity or by the time spent processing the call or by the
18 granularity of system timers.
19
21 0 on success, -1 on error.
22
24 EINTR Interrupted by a signal.
25
26 EINVAL usec is not smaller than 1000000. (On systems where that is
27 considered an error.)
28
30 4.3BSD, POSIX.1-2001. POSIX.1-2001 declares this function obsolete;
31 use nanosleep(2) instead.
32
33 On the original BSD implementation, and in glibc before version 2.2.2,
34 the return type of this function is void. The POSIX version returns
35 int, and this is also the prototype used since glibc 2.2.2.
36
37 Only the EINVAL error return is documented by SUSv2.
38
40 The type useconds_t is an unsigned integer type capable of holding
41 integers in the range [0,1000000]. Programs will be more portable if
42 they never mention this type explicitly. Use
43
44 #include <unistd.h>
45 ...
46 unsigned int usecs;
47 .
48 usleep(usecs);
49
50 The interaction of this function with the SIGALRM signal, and with
51 other timer functions such as alarm(), sleep(), nanosleep(),
52 setitimer(), timer_create(), timer_delete(), timer_getoverrun(),
53 timer_gettime(), timer_settime(), ualarm() is unspecified.
54
56 alarm(2), getitimer(2), nanosleep(2), select(2), setitimer(2),
57 ualarm(3), sleep(3), feature_test_macros(7), time(7)
58
59
60
61 2007-02-01 USLEEP(3)