1 .\" Copyright (c) 2002 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .TH sigwaitinfo 2 (date) "Linux man-pages (unreleased)"
7 sigwaitinfo, sigtimedwait, rt_sigtimedwait \- synchronously wait
11 .RI ( libc ", " \-lc )
14 .B #include <signal.h>
16 .BI "int sigwaitinfo(const sigset_t *restrict " set ,
17 .BI " siginfo_t *_Nullable restrict " info );
18 .BI "int sigtimedwait(const sigset_t *restrict " set ,
19 .BI " siginfo_t *_Nullable restrict " info ,
20 .BI " const struct timespec *restrict " timeout );
24 Feature Test Macro Requirements for glibc (see
25 .BR feature_test_macros (7)):
31 _POSIX_C_SOURCE >= 199309L
35 suspends execution of the calling thread until one of the signals in
38 (If one of the signals in
40 is already pending for the calling thread,
42 will return immediately.)
45 removes the signal from the set of pending
46 signals and returns the signal number as its function result.
50 then the buffer that it points to is used to return a structure of type
54 containing information about the signal.
56 If multiple signals in
58 are pending for the caller, the signal that is retrieved by
60 is determined according to the usual ordering rules; see
65 operates in exactly the same way as
67 except that it has an additional argument,
69 which specifies the interval for which
70 the thread is suspended waiting for a signal.
71 (This interval will be rounded up to the system clock granularity,
72 and kernel scheduling delays mean that the interval
73 may overrun by a small amount.)
78 If both fields of this structure are specified as 0, a poll is performed:
80 returns immediately, either with information about a signal that
81 was pending for the caller, or with an error
82 if none of the signals in
90 return a signal number (i.e., a value greater than zero).
91 On failure both calls return \-1, with
93 set to indicate the error.
99 became pending within the
105 The wait was interrupted by a signal handler; see
107 (This handler was for a signal other than one of those in
114 .SS C library/kernel differences
117 is a library function implemented on top of
120 The glibc wrapper functions for
124 silently ignore attempts to wait for the two real-time signals that
125 are used internally by the NPTL threading implementation.
130 The original Linux system call was named
132 However, with the addition of real-time signals in Linux 2.2,
133 the fixed-size, 32-bit
135 type supported by that system call was no longer fit for purpose.
136 Consequently, a new system call,
137 .BR rt_sigtimedwait (),
138 was added to support an enlarged
141 The new system call takes a fourth argument,
142 .IR "size_t sigsetsize" ,
143 which specifies the size in bytes of the signal set in
145 This argument is currently required to have the value
152 wrapper function hides these details from us, transparently calling
153 .BR rt_sigtimedwait ()
154 when the kernel provides it.
161 In normal usage, the calling program blocks the signals in
165 (so that the default disposition for these signals does not occur if they
166 become pending between successive calls to
170 and does not establish handlers for these signals.
171 In a multithreaded program,
172 the signal should be blocked in all threads, in order to prevent
173 the signal being treated according to its default disposition in
174 a thread other than the one calling
177 .BR sigtimedwait ()).
179 The set of signals that is pending for a given thread is the
180 union of the set of signals that is pending specifically for that thread
181 and the set of signals that is pending for the process as a whole (see
188 are silently ignored.
190 If multiple threads of a process are blocked
191 waiting for the same signal(s) in
195 then exactly one of the threads will actually receive the
196 signal if it becomes pending for the process as a whole;
197 which of the threads receives the signal is indeterminate.
202 can't be used to receive signals that
203 are synchronously generated, such as the
205 signal that results from accessing an invalid memory address
208 signal that results from an arithmetic error.
209 Such signals can be caught only via signal handler.
211 POSIX leaves the meaning of a NULL value for the
215 unspecified, permitting the possibility that this has the same meaning
218 and indeed this is what is done on Linux.