1.\" $OpenBSD: sleep.3,v 1.16 2020/02/08 01:09:57 jsg Exp $ 2.\" 3.\" Copyright (c) 1986, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.Dd $Mdocdate: February 8 2020 $ 31.Dt SLEEP 3 32.Os 33.Sh NAME 34.Nm sleep 35.Nd suspend process execution for interval measured in seconds 36.Sh SYNOPSIS 37.In unistd.h 38.Ft unsigned int 39.Fn sleep "unsigned int seconds" 40.Sh DESCRIPTION 41The 42.Fn sleep 43function suspends execution of the calling process until either 44.Fa seconds 45seconds have elapsed or a signal is delivered to the process and its 46action is to invoke a signal-catching function or to terminate the 47process. 48The suspension time may be longer than requested due to the 49scheduling of other activity by the system. 50.Pp 51This function is implemented using 52.Xr nanosleep 2 53by pausing for 54.Fa seconds 55seconds or until a signal occurs. 56Consequently, in this implementation, 57sleeping has no effect on the state of process timers, 58and there is no special handling for 59.Dv SIGALRM . 60.Sh RETURN VALUES 61If the 62.Fn sleep 63function returns because the requested time has elapsed, the value 64returned will be zero. 65If the 66.Fn sleep 67function returns due to the delivery of a signal, the value returned 68will be the unslept amount (the request time minus the time actually 69slept) in seconds. 70.Sh SEE ALSO 71.Xr sleep 1 , 72.Xr nanosleep 2 73.Sh STANDARDS 74The 75.Fn sleep 76function conforms to 77.St -p1003.1-90 . 78.Sh HISTORY 79A 80.Fn sleep 81system call first appeared in 82.At v2 . 83In 84.At v7 , 85it was removed and replaced by a C library implementation based on 86.Xr signal 3 87and 88.Xr alarm 3 . 89For 90.Ox 2.1 , 91it was reimplemented as a wrapper around the 92.Xr nanosleep 2 93system call. 94