1USLEEP(3P)                 POSIX Programmer's Manual                USLEEP(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       usleep - suspend execution for an interval
13

SYNOPSIS

15       #include <unistd.h>
16
17       int usleep(useconds_t useconds);
18
19

DESCRIPTION

21       The usleep() function shall cause the calling thread  to  be  suspended
22       from  execution until either the number of realtime microseconds speci‐
23       fied by the argument useconds has elapsed or a signal is  delivered  to
24       the  calling thread and its action is to invoke a signal-catching func‐
25       tion or to terminate the process.  The suspension time  may  be  longer
26       than requested due to the scheduling of other activity by the system.
27
28       The  useconds  argument shall be less than one million. If the value of
29       useconds is 0, then the call has no effect.
30
31       If a SIGALRM signal is generated for the calling process during  execu‐
32       tion  of usleep() and if the SIGALRM signal is being ignored or blocked
33       from delivery, it is unspecified  whether  usleep()  returns  when  the
34       SIGALRM signal is scheduled. If the signal is being blocked, it is also
35       unspecified whether it remains pending after usleep() returns or it  is
36       discarded.
37
38       If  a SIGALRM signal is generated for the calling process during execu‐
39       tion of usleep(), except as a result of a prior call to alarm(), and if
40       the SIGALRM signal is not being ignored or blocked from delivery, it is
41       unspecified whether that signal  has  any  effect  other  than  causing
42       usleep() to return.
43
44       If  a  signal-catching  function  interrupts  usleep()  and examines or
45       changes either the time a SIGALRM is scheduled  to  be  generated,  the
46       action  associated with the SIGALRM signal, or whether the SIGALRM sig‐
47       nal is blocked from delivery, the results are unspecified.
48
49       If a  signal-catching  function  interrupts  usleep()  and  calls  sig‐
50       longjmp()  or  longjmp()  to  restore an environment saved prior to the
51       usleep() call, the action associated with the SIGALRM  signal  and  the
52       time at which a SIGALRM signal is scheduled to be generated are unspec‐
53       ified. It is also unspecified whether the SIGALRM  signal  is  blocked,
54       unless the process' signal mask is restored as part of the environment.
55
56       Implementations  may place limitations on the granularity of timer val‐
57       ues. For each interval timer, if the requested timer value  requires  a
58       finer  granularity  than  the implementation supports, the actual timer
59       value shall be rounded up to the next supported value.
60
61       Interactions between usleep() and any of the following are unspecified:
62
63
64              nanosleep()
65              setitimer()
66              timer_create()
67              timer_delete()
68              timer_getoverrun()
69              timer_gettime()
70              timer_settime()
71              ualarm()
72              sleep()
73

RETURN VALUE

75       Upon successful completion, usleep()  shall  return  0;  otherwise,  it
76       shall return -1 and set errno to indicate the error.
77

ERRORS

79       The usleep() function may fail if:
80
81       EINVAL The time interval specified one million or more microseconds.
82
83
84       The following sections are informative.
85

EXAMPLES

87       None.
88

APPLICATION USAGE

90       Applications are recommended to use nanosleep() if the Timers option is
91       supported,    or    setitimer(),    timer_create(),     timer_delete(),
92       timer_getoverrun(), timer_gettime(), or timer_settime() instead of this
93       function.
94

RATIONALE

96       None.
97

FUTURE DIRECTIONS

99       None.
100

SEE ALSO

102       alarm(), getitimer(),  nanosleep(),  sigaction(),  sleep(),  timer_cre‐
103       ate(),  timer_delete(), timer_getoverrun(), the Base Definitions volume
104       of IEEE Std 1003.1-2001, <unistd.h>
105
107       Portions of this text are reprinted and reproduced in  electronic  form
108       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
109       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
110       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
111       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
112       event of any discrepancy between this version and the original IEEE and
113       The Open Group Standard, the original IEEE and The Open Group  Standard
114       is  the  referee document. The original Standard can be obtained online
115       at http://www.opengroup.org/unix/online.html .
116
117
118
119IEEE/The Open Group                  2003                           USLEEP(3P)
Impressum