xref: /original-bsd/lib/libc/gen/usleep.3 (revision a1c2194a)
1.\" Copyright (c) 1986, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)usleep.3	6.4 (Berkeley) 04/19/91
7.\"
8.Dd
9.Dt USLEEP 3
10.Os BSD 4.3
11.Sh NAME
12.Nm usleep
13.Nd suspend execution for interval of microseconds
14.Sh SYNOPSIS
15.Fd #include <unistd.h>
16.Ft void
17.Fn usleep "u_int microseconds"
18.Sh DESCRIPTION
19The
20.Fn sleep
21function
22suspends execution of the calling process
23for
24.Fa microseconds
25of time.
26System activity or time spent in processing the
27call may lengthen the sleep slightly.
28.Pp
29If a timer is already running on the process its state is saved.
30If the value
31.Fa microseconds
32is more than or equal to the remaining clock time for the saved timer,
33the sleep time is set to
34the remaining clock time.
35The state of the previous timer
36is restored after
37.Fa microseconds
38has passed.
39.Pp
40This routine is implemented using
41.Xr setitimer 2 ;
42it requires eight system calls each time it is invoked.
43A similar but less compatible function can be obtained with a single
44.Xr select 2 ;
45such a function would not restart after signals, but would not interfere
46with other uses of
47.Xr setitimer .
48.Sh SEE ALSO
49.Xr setitimer 2 ,
50.Xr getitimer 2 ,
51.Xr sigpause 2 ,
52.Xr ualarm 3 ,
53.Xr sleep 3 ,
54.Xr alarm 3
55.Sh HISTORY
56The
57.Fn usleep
58function appeared in
59.Bx 4.3 .
60