1SIGWAIT(3P)                POSIX Programmer's Manual               SIGWAIT(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       sigwait - wait for queued signals
13

SYNOPSIS

15       #include <signal.h>
16
17       int sigwait(const sigset_t *restrict set, int *restrict sig);
18
19

DESCRIPTION

21       The sigwait() function shall select a pending signal from  set,  atomi‐
22       cally  clear  it  from  the system's set of pending signals, and return
23       that signal number in the location referenced by sig. If prior  to  the
24       call to sigwait() there are multiple pending instances of a single sig‐
25       nal number, it is implementation-defined whether upon successful return
26       there are any remaining pending signals for that signal number.  If the
27       implementation supports queued signals and there are  multiple  signals
28       queued  for  the  signal  number selected, the first such queued signal
29       shall cause a return from sigwait()  and  the  remainder  shall  remain
30       queued.   If  no  signal in set is pending at the time of the call, the
31       thread shall be suspended until one or more becomes pending.  The  sig‐
32       nals  defined by set shall have been blocked at the time of the call to
33       sigwait(); otherwise, the behavior is undefined.  The  effect  of  sig‐
34       wait() on the signal actions for the signals in set is unspecified.
35
36       If more than one thread is using sigwait() to wait for the same signal,
37       no more than one of these threads shall return from sigwait() with  the
38       signal  number. Which thread returns from sigwait() if more than a sin‐
39       gle thread is waiting is unspecified.
40
41       Should any of the multiple pending signals in  the  range  SIGRTMIN  to
42       SIGRTMAX  be  selected, it shall be the lowest numbered one. The selec‐
43       tion order between realtime and non-realtime signals, or between multi‐
44       ple pending non-realtime signals, is unspecified.
45

RETURN VALUE

47       Upon  successful completion, sigwait() shall store the signal number of
48       the received signal at the location referenced by sig and return  zero.
49       Otherwise, an error number shall be returned to indicate the error.
50

ERRORS

52       The sigwait() function may fail if:
53
54       EINVAL The  set argument contains an invalid or unsupported signal num‐
55              ber.
56
57
58       The following sections are informative.
59

EXAMPLES

61       None.
62

APPLICATION USAGE

64       None.
65

RATIONALE

67       To provide a convenient way for a thread to wait  for  a  signal,  this
68       volume  of  IEEE Std 1003.1-2001  provides  the sigwait() function. For
69       most cases where a thread has to wait for a signal, the sigwait() func‐
70       tion should be quite convenient, efficient, and adequate.
71
72       However,  requests were made for a lower-level primitive than sigwait()
73       and for semaphores that could be used by threads.  After some consider‐
74       ation,  threads  were  allowed  to  use  semaphores  and sem_post() was
75       defined to be async-signal and async-cancel-safe.
76
77       In summary, when it is necessary for code run in response to  an  asyn‐
78       chronous  signal to notify a thread, sigwait() should be used to handle
79       the signal. Alternatively, if the implementation  provides  semaphores,
80       they also can be used, either following sigwait() or from within a sig‐
81       nal handling routine previously registered with sigaction().
82

FUTURE DIRECTIONS

84       None.
85

SEE ALSO

87       Signal Concepts, Realtime Signals, pause(),  pthread_sigmask(),  sigac‐
88       tion(), sigpending(), sigsuspend(), sigwaitinfo(), the Base Definitions
89       volume of IEEE Std 1003.1-2001, <signal.h>, <time.h>
90
92       Portions of this text are reprinted and reproduced in  electronic  form
93       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
94       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
95       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
96       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
97       event of any discrepancy between this version and the original IEEE and
98       The Open Group Standard, the original IEEE and The Open Group  Standard
99       is  the  referee document. The original Standard can be obtained online
100       at http://www.opengroup.org/unix/online.html .
101
102
103
104IEEE/The Open Group                  2003                          SIGWAIT(3P)
Impressum