1.\" $OpenBSD: nanosleep.2,v 1.7 2000/10/18 05:12:10 aaron Exp $ 2.\" $NetBSD: nanosleep.2,v 1.1 1997/04/17 18:12:02 jtc Exp $ 3.\" 4.\" Copyright (c) 1986, 1991, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)sleep.3 8.1 (Berkeley) 6/4/93 36.\" 37.Dd April 17, 1997 38.Dt NANOSLEEP 2 39.Os 40.Sh NAME 41.Nm nanosleep 42.Nd high resolution sleep 43.Sh SYNOPSIS 44.Fd #include <time.h> 45.Ft int 46.Fn nanosleep "const struct timespec *rqtp" "struct timespec *rmtp" 47.Sh DESCRIPTION 48.Fn nanosleep 49suspends execution of the calling process for the time specified. 50An unmasked signal will cause it to terminate the sleep early, 51regardless of the 52.Dv SA_RESTART 53value on the interrupting signal. 54.Sh RETURN VALUES 55If the 56.Fn nanosleep 57function returns because the requested time has elapsed, the value 58returned will be zero. 59.Pp 60If the 61.Fn nanosleep 62function returns due to the delivery of a signal, the value returned 63will be the \-1, and the global variable 64.Va errno 65will be set to indicate the interruption. 66If 67.Fa rmtp 68is non-null, the timespec structure it references is updated to contain the 69unslept amount (the request time minus the time actually slept). 70.Sh ERRORS 71If any of the following conditions occur, the 72.Fn nanosleep 73function shall return \-1 and set 74.Va errno 75to the corresponding value. 76.Bl -tag -width Er 77.It Bq Er EFAULT 78Either 79.Fa rqtp 80or 81.Fa rmtp 82points to memory that is not a valid part of the process address space. 83.It Bq Er EINTR 84.Nm 85was interrupted by the delivery of a signal. 86.It Bq Er EINVAL 87.Fa rqtp 88specified a nanosecond value less than zero or greater than 1000 million, 89or a second value less than zero or greater than 100 million. 90.It Bq Er ENOSYS 91.Nm 92is not supported by this implementation. 93.El 94.Sh SEE ALSO 95.Xr sleep 3 96.Sh STANDARDS 97The 98.Fn nanosleep 99function conforms to 100.St -p1003.1b-93 . 101