1USLEEP(3)                  Linux Programmer's Manual                 USLEEP(3)
2
3
4

NAME

6       usleep - suspend execution for microsecond intervals
7

SYNOPSIS

9       #include <unistd.h>
10
11       int usleep(useconds_t usec);
12
13   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15       usleep():
16           Since glibc 2.12:
17               (_XOPEN_SOURCE >= 500) && ! (_POSIX_C_SOURCE >= 200809L)
18                   || /* Glibc since 2.19: */ _DEFAULT_SOURCE
19                   || /* Glibc versions <= 2.19: */ _BSD_SOURCE
20           Before glibc 2.12:
21               _BSD_SOURCE || _XOPEN_SOURCE >= 500
22

DESCRIPTION

24       The  usleep() function suspends execution of the calling thread for (at
25       least) usec microseconds.  The sleep may be lengthened slightly by  any
26       system  activity  or  by  the  time spent processing the call or by the
27       granularity of system timers.
28

RETURN VALUE

30       The usleep() function returns 0 on success.  On error, -1 is  returned,
31       with errno set to indicate the cause of the error.
32

ERRORS

34       EINTR  Interrupted by a signal; see signal(7).
35
36       EINVAL usec  is  greater  than  or equal to 1000000.  (On systems where
37              that is considered an error.)
38

ATTRIBUTES

40       For  an  explanation  of  the  terms  used   in   this   section,   see
41       attributes(7).
42
43       ┌──────────┬───────────────┬─────────┐
44Interface Attribute     Value   
45       ├──────────┼───────────────┼─────────┤
46usleep()  │ Thread safety │ MT-Safe │
47       └──────────┴───────────────┴─────────┘

CONFORMING TO

49       4.3BSD,  POSIX.1-2001.   POSIX.1-2001  declares this function obsolete;
50       use nanosleep(2) instead.  POSIX.1-2008 removes  the  specification  of
51       usleep().
52
53       On  the original BSD implementation, and in glibc before version 2.2.2,
54       the return type of this function is void.  The  POSIX  version  returns
55       int, and this is also the prototype used since glibc 2.2.2.
56
57       Only the EINVAL error return is documented by SUSv2 and POSIX.1-2001.
58

NOTES

60       The  type  useconds_t  is  an  unsigned integer type capable of holding
61       integers in the range [0,1000000].  Programs will be more  portable  if
62       they never mention this type explicitly.  Use
63
64           #include <unistd.h>
65           ...
66               unsigned int usecs;
67           ...
68               usleep(usecs);
69
70       The  interaction  of  this  function  with the SIGALRM signal, and with
71       other  timer  functions  such  as  alarm(2),  sleep(3),   nanosleep(2),
72       setitimer(2),  timer_create(2),  timer_delete(2),  timer_getoverrun(2),
73       timer_gettime(2), timer_settime(2), ualarm(3) is unspecified.
74

SEE ALSO

76       alarm(2),   getitimer(2),   nanosleep(2),   select(2),    setitimer(2),
77       sleep(3), ualarm(3), time(7)
78

COLOPHON

80       This  page  is  part of release 5.07 of the Linux man-pages project.  A
81       description of the project, information about reporting bugs,  and  the
82       latest     version     of     this    page,    can    be    found    at
83       https://www.kernel.org/doc/man-pages/.
84
85
86
87                                  2017-09-15                         USLEEP(3)
Impressum