SIGWAIT(3)                 POSIX Programmer's Manual                SIGWAIT(3)



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

NNAAMMEE
       sigwait -- wait for queued signals

SSYYNNOOPPSSIISS
       #include <signal.h>

       int sigwait(const sigset_t *restrict _s_e_t, int *restrict _s_i_g);

DDEESSCCRRIIPPTTIIOONN
       The _s_i_g_w_a_i_t() function shall select a pending signal from _s_e_t,
       atomically clear it from the system's set of pending signals, and
       return that signal number in the location referenced by _s_i_g.  If prior
       to the call to _s_i_g_w_a_i_t() there are multiple pending instances of a
       single signal number, it is implementation-defined whether upon
       successful return there are any remaining pending signals for that
       signal number.  If the implementation supports queued signals and there
       are multiple signals queued for the signal number selected, the first
       such queued signal shall cause a return from _s_i_g_w_a_i_t() and the
       remainder shall remain queued. If no signal in _s_e_t is pending at the
       time of the call, the thread shall be suspended until one or more
       becomes pending. The signals defined by _s_e_t shall have been blocked at
       the time of the call to _s_i_g_w_a_i_t(); otherwise, the behavior is
       undefined. The effect of _s_i_g_w_a_i_t() on the signal actions for the
       signals in _s_e_t is unspecified.

       If more than one thread is using _s_i_g_w_a_i_t() to wait for the same signal,
       no more than one of these threads shall return from _s_i_g_w_a_i_t() with the
       signal number. If more than a single thread is blocked in _s_i_g_w_a_i_t() for
       a signal when that signal is generated for the process, it is
       unspecified which of the waiting threads returns from _s_i_g_w_a_i_t().  If
       the signal is generated for a specific thread, as by _p_t_h_r_e_a_d___k_i_l_l(),
       only that thread shall return.

       Should any of the multiple pending signals in the range SIGRTMIN to
       SIGRTMAX be selected, it shall be the lowest numbered one. The
       selection order between realtime and non-realtime signals, or between
       multiple pending non-realtime signals, is unspecified.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, _s_i_g_w_a_i_t() shall store the signal number of
       the received signal at the location referenced by _s_i_g and return zero.
       Otherwise, an error number shall be returned to indicate the error.

EERRRROORRSS
       The _s_i_g_w_a_i_t() function may fail if:

       EEIINNVVAALL The _s_e_t argument contains an invalid or unsupported signal
              number.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       None.

RRAATTIIOONNAALLEE
       To provide a convenient way for a thread to wait for a signal, this
       volume of POSIX.1-2017 provides the _s_i_g_w_a_i_t() function. For most cases
       where a thread has to wait for a signal, the _s_i_g_w_a_i_t() function should
       be quite convenient, efficient, and adequate.

       However, requests were made for a lower-level primitive than _s_i_g_w_a_i_t()
       and for semaphores that could be used by threads. After some
       consideration, threads were allowed to use semaphores and _s_e_m___p_o_s_t()
       was defined to be async-signal-safe.

       In summary, when it is necessary for code run in response to an
       asynchronous signal to notify a thread, _s_i_g_w_a_i_t() should be used to
       handle the signal. Alternatively, if the implementation provides
       semaphores, they also can be used, either following _s_i_g_w_a_i_t() or from
       within a signal handling routine previously registered with
       _s_i_g_a_c_t_i_o_n().

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _S_e_c_t_i_o_n _2_._4, _S_i_g_n_a_l _C_o_n_c_e_p_t_s, _S_e_c_t_i_o_n _2_._8_._1, _R_e_a_l_t_i_m_e _S_i_g_n_a_l_s, _p_a_u_s_e(),
       _p_t_h_r_e_a_d___s_i_g_m_a_s_k(), _s_i_g_a_c_t_i_o_n(), _s_i_g_p_e_n_d_i_n_g(), _s_i_g_s_u_s_p_e_n_d(),
       _s_i_g_t_i_m_e_d_w_a_i_t()

       The Base Definitions volume of POSIX.1-2017, <<ssiiggnnaall..hh>>, <<ttiimmee..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the
       Institute of Electrical and Electronics Engineers, Inc and The Open
       Group.  In the event of any discrepancy between this version and the
       original IEEE and The Open Group Standard, the original IEEE and The
       Open Group Standard is the referee document. The original Standard can
       be obtained online at http://www.opengroup.org/unix/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2017                           SIGWAIT(3)
