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

NAME

6       sigwait - wait for queued signals
7

SYNOPSIS

9       #include <signal.h>
10
11       int sigwait(const sigset_t *restrict set, int *restrict sig);
12
13

DESCRIPTION

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

RETURN VALUE

41       Upon successful completion, sigwait() shall store the signal number  of
42       the  received signal at the location referenced by sig and return zero.
43       Otherwise, an error number shall be returned to indicate the error.
44

ERRORS

46       The sigwait() function may fail if:
47
48       EINVAL The set argument contains an invalid or unsupported signal  num‐
49              ber.
50
51
52       The following sections are informative.
53

EXAMPLES

55       None.
56

APPLICATION USAGE

58       None.
59

RATIONALE

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

FUTURE DIRECTIONS

78       None.
79

SEE ALSO

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