logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

nanosleep.3p (4649B)


  1. '\" et
  2. .TH NANOSLEEP "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. nanosleep
  12. \(em high resolution sleep
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <time.h>
  17. .P
  18. int nanosleep(const struct timespec *\fIrqtp\fP, struct timespec *\fIrmtp\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fInanosleep\fR()
  23. function shall cause the current thread to be suspended from execution
  24. until either the time interval specified by the
  25. .IR rqtp
  26. argument has elapsed or a signal is delivered to the calling thread,
  27. and its action is to invoke a signal-catching function or to terminate
  28. the process. The suspension time may be longer than requested because
  29. the argument value is rounded up to an integer multiple of the sleep
  30. resolution or because of the scheduling of other activity by the
  31. system. But, except for the case of being interrupted by a signal, the
  32. suspension time shall not be less than the time specified by
  33. .IR rqtp ,
  34. as measured by the system clock CLOCK_REALTIME.
  35. .P
  36. The use of the
  37. \fInanosleep\fR()
  38. function has no effect on the action or blockage of any signal.
  39. .SH "RETURN VALUE"
  40. If the
  41. \fInanosleep\fR()
  42. function returns because the requested time has elapsed, its return
  43. value shall be zero.
  44. .P
  45. If the
  46. \fInanosleep\fR()
  47. function returns because it has been interrupted by a signal, it
  48. shall return a value of \-1 and set
  49. .IR errno
  50. to indicate the interruption. If the
  51. .IR rmtp
  52. argument is non-NULL, the
  53. .BR timespec
  54. structure referenced by it is updated to contain the amount of time
  55. remaining in the interval (the requested time minus the time actually
  56. slept). The
  57. .IR rqtp
  58. and
  59. .IR rmtp
  60. arguments can point to the same object. If the
  61. .IR rmtp
  62. argument is NULL, the remaining time is not returned.
  63. .P
  64. If
  65. \fInanosleep\fR()
  66. fails, it shall return a value of \-1 and set
  67. .IR errno
  68. to indicate the error.
  69. .SH ERRORS
  70. The
  71. \fInanosleep\fR()
  72. function shall fail if:
  73. .TP
  74. .BR EINTR
  75. The
  76. \fInanosleep\fR()
  77. function was interrupted by a signal.
  78. .TP
  79. .BR EINVAL
  80. The
  81. .IR rqtp
  82. argument specified a nanosecond value less than zero or greater than or
  83. equal to 1\|000 million.
  84. .LP
  85. .IR "The following sections are informative."
  86. .SH EXAMPLES
  87. None.
  88. .SH "APPLICATION USAGE"
  89. None.
  90. .SH RATIONALE
  91. It is common to suspend execution of a thread for an interval in order
  92. to poll the status of a non-interrupting function. A large number of
  93. actual needs can be met with a simple extension to
  94. \fIsleep\fR()
  95. that provides finer resolution.
  96. .P
  97. In the POSIX.1\(hy1990 standard and SVR4, it is possible to implement such a routine,
  98. but the frequency of wakeup is limited by the resolution of the
  99. \fIalarm\fR()
  100. and
  101. \fIsleep\fR()
  102. functions. In 4.3 BSD, it is possible to write such a routine using
  103. no static storage and reserving no system facilities. Although it is
  104. possible to write a function with similar functionality to
  105. \fIsleep\fR()
  106. using the remainder of the
  107. .IR timer_* (\|)
  108. functions, such a function requires the use of signals and the
  109. reservation of some signal number. This volume of POSIX.1\(hy2017 requires that
  110. \fInanosleep\fR()
  111. be non-intrusive of the signals function.
  112. .P
  113. The
  114. \fInanosleep\fR()
  115. function shall return a value of 0 on success and \-1 on failure or if
  116. interrupted. This latter case is different from
  117. \fIsleep\fR().
  118. This was done because the remaining time is returned via an argument
  119. structure pointer,
  120. .IR rmtp ,
  121. instead of as the return value.
  122. .SH "FUTURE DIRECTIONS"
  123. None.
  124. .SH "SEE ALSO"
  125. .IR "\fIclock_nanosleep\fR\^(\|)",
  126. .IR "\fIsleep\fR\^(\|)"
  127. .P
  128. The Base Definitions volume of POSIX.1\(hy2017,
  129. .IR "\fB<time.h>\fP"
  130. .\"
  131. .SH COPYRIGHT
  132. Portions of this text are reprinted and reproduced in electronic form
  133. from IEEE Std 1003.1-2017, Standard for Information Technology
  134. -- Portable Operating System Interface (POSIX), The Open Group Base
  135. Specifications Issue 7, 2018 Edition,
  136. Copyright (C) 2018 by the Institute of
  137. Electrical and Electronics Engineers, Inc and The Open Group.
  138. In the event of any discrepancy between this version and the original IEEE and
  139. The Open Group Standard, the original IEEE and The Open Group Standard
  140. is the referee document. The original Standard can be obtained online at
  141. http://www.opengroup.org/unix/online.html .
  142. .PP
  143. Any typographical or formatting errors that appear
  144. in this page are most likely
  145. to have been introduced during the conversion of the source files to
  146. man page format. To report such errors, see
  147. https://www.kernel.org/doc/man-pages/reporting_bugs.html .