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               _BSD_SOURCE ||
18                   (_XOPEN_SOURCE >= 500 ||
19                       _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) &&
20                   !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
21           Before glibc 2.12:
22               _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
23               _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
24

DESCRIPTION

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

RETURN VALUE

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

ERRORS

36       EINTR  Interrupted by a signal; see signal(7).
37
38       EINVAL usec is not smaller than 1000000.  (On  systems  where  that  is
39              considered an error.)
40

CONFORMING TO

42       4.3BSD,  POSIX.1-2001.   POSIX.1-2001  declares this function obsolete;
43       use nanosleep(2) instead.  POSIX.1-2008 removes  the  specification  of
44       usleep().
45
46       On  the original BSD implementation, and in glibc before version 2.2.2,
47       the return type of this function is void.  The  POSIX  version  returns
48       int, and this is also the prototype used since glibc 2.2.2.
49
50       Only the EINVAL error return is documented by SUSv2 and POSIX.1-2001.
51

NOTES

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

SEE ALSO

69       alarm(2),   getitimer(2),   nanosleep(2),   select(2),    setitimer(2),
70       sleep(3), ualarm(3), time(7)
71

COLOPHON

73       This  page  is  part of release 3.53 of the Linux man-pages project.  A
74       description of the project, and information about reporting  bugs,  can
75       be found at http://www.kernel.org/doc/man-pages/.
76
77
78
79                                  2013-04-19                         USLEEP(3)
Impressum