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

sigwait.3p (4941B)


  1. '\" et
  2. .TH SIGWAIT "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. sigwait
  12. \(em wait for queued signals
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <signal.h>
  17. .P
  18. int sigwait(const sigset_t *restrict \fIset\fP, int *restrict \fIsig\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIsigwait\fR()
  23. function shall select a pending signal from
  24. .IR set ,
  25. atomically clear it from the system's set of pending signals, and
  26. return that signal number in the location referenced by
  27. .IR sig .
  28. If prior to the call to
  29. \fIsigwait\fR()
  30. there are multiple pending instances of a single signal number, it is
  31. implementation-defined whether upon successful return there are any
  32. remaining pending signals for that signal number.
  33. If the implementation supports queued signals and there are multiple
  34. signals queued for the signal number selected, the first such queued
  35. signal shall cause a return from
  36. \fIsigwait\fR()
  37. and the remainder shall remain queued. If no signal in
  38. .IR set
  39. is pending at the time of the call, the thread shall be suspended
  40. until one or more becomes pending. The signals defined by
  41. .IR set
  42. shall have been blocked at the time of the call to
  43. \fIsigwait\fR();
  44. otherwise, the behavior is undefined. The effect of
  45. \fIsigwait\fR()
  46. on the signal actions for the signals in
  47. .IR set
  48. is unspecified.
  49. .P
  50. If more than one thread is using
  51. \fIsigwait\fR()
  52. to wait for the same signal, no more than one of these threads shall
  53. return from
  54. \fIsigwait\fR()
  55. with the signal number. If more than a single thread is blocked in
  56. \fIsigwait\fR()
  57. for a signal when that signal is generated for the process, it is
  58. unspecified which of the waiting threads returns from
  59. \fIsigwait\fR().
  60. If the signal is generated for a specific thread, as by
  61. \fIpthread_kill\fR(),
  62. only that thread shall return.
  63. .P
  64. Should any of the multiple pending signals in the range SIGRTMIN to
  65. SIGRTMAX be selected, it shall be the lowest numbered one. The
  66. selection order between realtime and non-realtime signals, or between
  67. multiple pending non-realtime signals, is unspecified.
  68. .SH "RETURN VALUE"
  69. Upon successful completion,
  70. \fIsigwait\fR()
  71. shall store the signal number of the received signal at the location
  72. referenced by
  73. .IR sig
  74. and return zero. Otherwise, an error number shall be returned to
  75. indicate the error.
  76. .SH ERRORS
  77. The
  78. \fIsigwait\fR()
  79. function may fail if:
  80. .TP
  81. .BR EINVAL
  82. The
  83. .IR set
  84. argument contains an invalid or unsupported signal number.
  85. .LP
  86. .IR "The following sections are informative."
  87. .SH EXAMPLES
  88. None.
  89. .SH "APPLICATION USAGE"
  90. None.
  91. .SH RATIONALE
  92. To provide a convenient way for a thread to wait for a signal, this volume of POSIX.1\(hy2017
  93. provides the
  94. \fIsigwait\fR()
  95. function. For most cases where a thread has to wait for a signal, the
  96. \fIsigwait\fR()
  97. function should be quite convenient, efficient, and adequate.
  98. .P
  99. However, requests were made for a lower-level primitive than
  100. \fIsigwait\fR()
  101. and for semaphores that could be used by threads. After some
  102. consideration, threads were allowed to use semaphores and
  103. \fIsem_post\fR()
  104. was defined to be async-signal-safe.
  105. .P
  106. In summary, when it is necessary for code run in response to an
  107. asynchronous signal to notify a thread,
  108. \fIsigwait\fR()
  109. should be used to handle the signal. Alternatively, if the
  110. implementation provides semaphores, they also can be used, either
  111. following
  112. \fIsigwait\fR()
  113. or from within a signal handling routine previously registered with
  114. \fIsigaction\fR().
  115. .SH "FUTURE DIRECTIONS"
  116. None.
  117. .SH "SEE ALSO"
  118. .IR "Section 2.4" ", " "Signal Concepts",
  119. .IR "Section 2.8.1" ", " "Realtime Signals",
  120. .IR "\fIpause\fR\^(\|)",
  121. .IR "\fIpthread_sigmask\fR\^(\|)",
  122. .IR "\fIsigaction\fR\^(\|)",
  123. .IR "\fIsigpending\fR\^(\|)",
  124. .IR "\fIsigsuspend\fR\^(\|)",
  125. .IR "\fIsigtimedwait\fR\^(\|)"
  126. .P
  127. The Base Definitions volume of POSIX.1\(hy2017,
  128. .IR "\fB<signal.h>\fP",
  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 .