2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 2016 Joyent, Inc.
4 .\" Copyright 1989 AT&T
5 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
6 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
7 .\" http://www.opengroup.org/bookstore/.
8 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
9 .\" This notice shall appear on any product containing this material.
10 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
11 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
12 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
13 .TH NANOSLEEP 3C "Mar 27, 2016"
15 nanosleep, thrd_sleep \- high resolution sleep
21 \fBint\fR \fBnanosleep\fR(\fBconst struct timespec *\fR\fIrqtp\fR,
22 \fBstruct timespec *\fR\fIrmtp\fR);
28 \fBint\fR \fBthrd_sleep\fR(\fBconst struct timespec *\fR\fIrqtp\fR,
29 \fBstruct timespec *\fR\fIrmtp\fR);
33 The \fBnanosleep()\fR and \fBthrd_sleep()\fR functions cause the current thread
34 to be suspended from execution until either the time interval specified by the
35 \fIrqtp\fR argument has elapsed or a signal is delivered to the calling thread
36 and its action is to invoke a signal-catching function or to terminate the
37 process. The suspension time may be longer than requested because the argument
38 value is rounded up to an integer multiple of the sleep resolution or because of
39 the scheduling of other activity by the system. But, except for the case of
40 being interrupted by a signal, the suspension time will not be less than the
41 time specified by \fIrqtp\fR, as measured by the system clock,
45 The use of the \fBnanosleep()\fR and \fBthrd_sleep()\fR functions has no effect
46 on the action or blockage of any signal.
49 If the \fBnanosleep()\fR or \fBthrd_sleep()\fR function returns because the
50 requested time has elapsed, its return value is \fB0\fR.
53 If the \fBnanosleep()\fR function returns because it has been interrupted by a
54 signal, the function returns a value of \(mi1 and sets \fBerrno\fR to indicate
55 the interruption. If the \fIrmtp\fR argument is non-\fINULL\fR, the
56 \fBtimespec\fR structure referenced by it is updated to contain the amount of
57 time remaining in the interval (the requested time minus the time actually
58 slept). If the \fIrmtp\fR argument is \fINULL\fR, the remaining time is not
62 If \fBnanosleep()\fR fails, it returns \fB\(mi1\fR and sets \fBerrno\fR to
69 function may fail for identical reasons as the
71 function and returns \(mi1; however, the C11 standard does not define that
73 should be set, therefore callers of \fBthrd_sleep()\fR cannot rely on
75 being set or staying the same across a call to
80 The \fBnanosleep()\fR function will fail if:
87 The \fBnanosleep()\fR function was interrupted by a signal.
96 The \fIrqtp\fR argument specified a nanosecond value less than zero or greater
97 than or equal to 1000 million.
106 The \fBnanosleep()\fR function is not supported by this implementation.
111 See \fBattributes\fR(5) for descriptions of the following attributes:
119 ATTRIBUTE TYPE ATTRIBUTE VALUE
121 Interface Stability Committed
125 Standard See \fBstandards\fR(5).
130 \fBsleep\fR(3C), \fBtime.h\fR(3HEAD), \fBattributes\fR(5), \fBstandards\fR(5)