summaryrefslogtreecommitdiff
path: root/lib/libc/gen/sleep.3
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2012-10-16 18:35:41 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2012-10-16 18:35:41 +0000
commit36f1355a25c3c5f41f9c1e4b588c8bc1efc46da9 (patch)
tree07445cff6be5fdf6eee04626c5cd1b11318ab8df /lib/libc/gen/sleep.3
parentf3c6946fe24b64f2be83ce90d79fc56b23c09c32 (diff)
Make sleep(3) and usleep(3) more consistent and remove extraneous
historic implementation details that get in the way of readability. Our usleep(3) does not return EINVAL for values >= 1,000,000 but still mention it in CAVEATS since some do. Portions adapted from FreeBSD. OK jmc@
Diffstat (limited to 'lib/libc/gen/sleep.3')
-rw-r--r--lib/libc/gen/sleep.338
1 files changed, 15 insertions, 23 deletions
diff --git a/lib/libc/gen/sleep.3 b/lib/libc/gen/sleep.3
index de0d7974faf..a112aded241 100644
--- a/lib/libc/gen/sleep.3
+++ b/lib/libc/gen/sleep.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sleep.3,v 1.11 2008/10/24 14:34:39 jmc Exp $
+.\" $OpenBSD: sleep.3,v 1.12 2012/10/16 18:35:40 millert Exp $
.\"
.\" Copyright (c) 1986, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -27,12 +27,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: October 24 2008 $
+.Dd $Mdocdate: October 16 2012 $
.Dt SLEEP 3
.Os
.Sh NAME
.Nm sleep
-.Nd suspend process execution for interval of seconds
+.Nd suspend process execution for interval measured in seconds
.Sh SYNOPSIS
.Fd #include <unistd.h>
.Ft unsigned int
@@ -40,25 +40,23 @@
.Sh DESCRIPTION
The
.Fn sleep
-function suspends execution of the calling process until either the
-number of seconds specified by
+function suspends execution of the calling process until either
.Fa seconds
-have elapsed or a signal is delivered to the calling process and its
-action is to invoke a signal-catching function or to terminate the process.
+seconds have elapsed or a signal is delivered to the process and its
+action is to invoke a signal-catching function or to terminate the
+process.
The suspension time may be longer than requested due to the
scheduling of other activity by the system.
.Pp
This function is implemented using
-.Xr nanosleep 2 ;
-it requires one system call each time it is invoked.
-A similar but less compatible function can be obtained with a single
-.Xr select 2 ;
-such a function would not restart after signals, and also does not interfere
-with other uses of
-.Xr setitimer 2
-(not that
-.Fn sleep
-interferes with interval timers anymore).
+.Xr nanosleep 2
+by pausing for
+.Fa seconds
+seconds or until a signal occurs.
+Consequently, in this implementation,
+sleeping has no effect on the state of process timers,
+and there is no special handling for
+.Dv SIGALRM .
.Sh RETURN VALUES
If the
.Fn sleep
@@ -72,12 +70,6 @@ slept) in seconds.
.Sh SEE ALSO
.Xr sleep 1 ,
.Xr nanosleep 2 ,
-.Xr select 2 ,
-.Xr setitimer 2 ,
-.Xr sigaction 2 ,
-.Xr sigsuspend 2 ,
-.Xr alarm 3 ,
-.Xr pause 3 ,
.Xr usleep 3
.Sh STANDARDS
The