1 .\" Copyright (c) 2002 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH SIGWAITINFO 2 2021-03-22 "Linux" "Linux Programmer's Manual"
27 sigwaitinfo, sigtimedwait, rt_sigtimedwait \- synchronously wait
31 .B #include <signal.h>
33 .BI "int sigwaitinfo(const sigset_t *restrict " set ,
34 .BI " siginfo_t *restrict " info );
35 .BI "int sigtimedwait(const sigset_t *restrict " set ,
36 .BI " siginfo_t *restrict " info ,
37 .BI " const struct timespec *restrict " timeout );
41 Feature Test Macro Requirements for glibc (see
42 .BR feature_test_macros (7)):
48 _POSIX_C_SOURCE >= 199309L
52 suspends execution of the calling thread until one of the signals in
55 (If one of the signals in
57 is already pending for the calling thread,
59 will return immediately.)
62 removes the signal from the set of pending
63 signals and returns the signal number as its function result.
67 then the buffer that it points to is used to return a structure of type
71 containing information about the signal.
73 If multiple signals in
75 are pending for the caller, the signal that is retrieved by
77 is determined according to the usual ordering rules; see
82 operates in exactly the same way as
84 except that it has an additional argument,
86 which specifies the interval for which
87 the thread is suspended waiting for a signal.
88 (This interval will be rounded up to the system clock granularity,
89 and kernel scheduling delays mean that the interval
90 may overrun by a small amount.)
91 This argument is of the following type:
96 long tv_sec; /* seconds */
97 long tv_nsec; /* nanoseconds */
102 If both fields of this structure are specified as 0, a poll is performed:
104 returns immediately, either with information about a signal that
105 was pending for the caller, or with an error
106 if none of the signals in
114 return a signal number (i.e., a value greater than zero).
115 On failure both calls return \-1, with
117 set to indicate the error.
123 became pending within the
129 The wait was interrupted by a signal handler; see
131 (This handler was for a signal other than one of those in
138 POSIX.1-2001, POSIX.1-2008.
140 In normal usage, the calling program blocks the signals in
144 (so that the default disposition for these signals does not occur if they
145 become pending between successive calls to
149 and does not establish handlers for these signals.
150 In a multithreaded program,
151 the signal should be blocked in all threads, in order to prevent
152 the signal being treated according to its default disposition in
153 a thread other than the one calling
156 .BR sigtimedwait ()).
158 The set of signals that is pending for a given thread is the
159 union of the set of signals that is pending specifically for that thread
160 and the set of signals that is pending for the process as a whole (see
167 are silently ignored.
169 If multiple threads of a process are blocked
170 waiting for the same signal(s) in
174 then exactly one of the threads will actually receive the
175 signal if it becomes pending for the process as a whole;
176 which of the threads receives the signal is indeterminate.
181 can't be used to receive signals that
182 are synchronously generated, such as the
184 signal that results from accessing an invalid memory address
187 signal that results from an arithmetic error.
188 Such signals can be caught only via signal handler.
190 POSIX leaves the meaning of a NULL value for the
194 unspecified, permitting the possibility that this has the same meaning
197 and indeed this is what is done on Linux.
199 .SS C library/kernel differences
202 is a library function implemented on top of
205 The glibc wrapper functions for
209 silently ignore attempts to wait for the two real-time signals that
210 are used internally by the NPTL threading implementation.
215 The original Linux system call was named
217 However, with the addition of real-time signals in Linux 2.2,
218 the fixed-size, 32-bit
220 type supported by that system call was no longer fit for purpose.
221 Consequently, a new system call,
222 .BR rt_sigtimedwait (),
223 was added to support an enlarged
226 The new system call takes a fourth argument,
227 .IR "size_t sigsetsize" ,
228 which specifies the size in bytes of the signal set in
230 This argument is currently required to have the value
237 wrapper function hides these details from us, transparently calling
238 .BR rt_sigtimedwait ()
239 when the kernel provides it.