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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

62       None.
63

APPLICATION USAGE

65       None.
66

RATIONALE

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

FUTURE DIRECTIONS

85       None.
86

SEE ALSO

88       Section 2.4, Signal Concepts, Section 2.8.1, Realtime Signals, pause(),
89       pthread_sigmask(), sigaction(), sigpending(),  sigsuspend(),  sigtimed‐
90       wait()
91
92       The Base Definitions volume of POSIX.1‐2017, <signal.h>, <time.h>
93
95       Portions  of  this text are reprinted and reproduced in electronic form
96       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
97       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
98       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
99       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
100       event of any discrepancy between this version and the original IEEE and
101       The  Open Group Standard, the original IEEE and The Open Group Standard
102       is the referee document. The original Standard can be  obtained  online
103       at http://www.opengroup.org/unix/online.html .
104
105       Any  typographical  or  formatting  errors that appear in this page are
106       most likely to have been introduced during the conversion of the source
107       files  to  man page format. To report such errors, see https://www.ker
108       nel.org/doc/man-pages/reporting_bugs.html .
109
110
111
112IEEE/The Open Group                  2017                          SIGWAIT(3P)
Impressum