Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
NANOSLEEP(2)		  FreeBSD System Calls Manual		  NANOSLEEP(2)

NAME
     nanosleep -- high resolution sleep

SYNOPSIS
     #include <time.h>

     int
     nanosleep(const struct timespec *timeout, struct timespec *remainder);

DESCRIPTION
     nanosleep() suspends execution of the calling process for the duration
     specified by timeout.  An unmasked	signal will cause it to	terminate the
     sleep early, regardless of	the SA_RESTART value on	the interrupting sig-
     nal.

RETURN VALUES
     If	the nanosleep()	function returns because the requested duration	has
     elapsed, the value	returned will be zero.

     If	the nanosleep()	function returns due to	the delivery of	a signal, the
     value returned will be -1,	and the	global variable	errno will be set to
     indicate the interruption.	 If remainder is non-null, the timespec	struc-
     ture it references	is updated to contain the unslept amount (the re-
     quested duration minus the	duration actually slept).

ERRORS
     If	any of the following conditions	occur, the nanosleep() function	shall
     return -1 and set errno to	the corresponding value.

     [EINTR]		nanosleep() was	interrupted by the delivery of a sig-
			nal.

     [EINVAL]		timeout	specified a nanosecond value less than zero or
			greater	than or	equal to 1000 million, or a second
			value less than	zero.

     [EFAULT]		Either timeout or remainder points to memory that is
			not a valid part of the	process	address	space.

SEE ALSO
     sleep(1), sleep(3)

STANDARDS
     The nanosleep() function conforms to IEEE Std 1003.1-2008 ("POSIX.1").

HISTORY
     The predecessor of	this system call, sleep(), appeared in Version 3 AT&T
     UNIX, but was removed when	alarm(3) was introduced	into Version 7 AT&T
     UNIX.  The	nanosleep() system call	has been available since NetBSD	1.3
     and was ported to OpenBSD 2.1 and FreeBSD 3.0.

FreeBSD	13.0		       December	31, 2018		  FreeBSD 13.0

NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | SEE ALSO | STANDARDS | HISTORY

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=nanosleep&sektion=2&manpath=OpenBSD+6.9>

home | help