1sigwaitinfo(2)                System Calls Manual               sigwaitinfo(2)
2
3
4

NAME

6       sigwaitinfo,  sigtimedwait,  rt_sigtimedwait  -  synchronously wait for
7       queued signals
8

LIBRARY

10       Standard C library (libc, -lc)
11

SYNOPSIS

13       #include <signal.h>
14
15       int sigwaitinfo(const sigset_t *restrict set,
16                       siginfo_t *_Nullable restrict info);
17       int sigtimedwait(const sigset_t *restrict set,
18                       siginfo_t *_Nullable restrict info,
19                       const struct timespec *restrict timeout);
20
21   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
22
23       sigwaitinfo(), sigtimedwait():
24           _POSIX_C_SOURCE >= 199309L
25

DESCRIPTION

27       sigwaitinfo() suspends execution of the calling thread until one of the
28       signals  in  set  is  pending  (If one of the signals in set is already
29       pending for the calling thread, sigwaitinfo() will return immediately.)
30
31       sigwaitinfo() removes the signal from the set of  pending  signals  and
32       returns the signal number as its function result.  If the info argument
33       is not NULL, then the buffer that it points to  is  used  to  return  a
34       structure  of  type siginfo_t (see sigaction(2)) containing information
35       about the signal.
36
37       If multiple signals in set are pending for the caller, the signal  that
38       is  retrieved by sigwaitinfo() is determined according to the usual or‐
39       dering rules; see signal(7) for further details.
40
41       sigtimedwait() operates in exactly the same way as sigwaitinfo() except
42       that it has an additional argument, timeout, which specifies the inter‐
43       val for which the thread is suspended waiting for a signal.  (This  in‐
44       terval  will  be rounded up to the system clock granularity, and kernel
45       scheduling delays mean  that  the  interval  may  overrun  by  a  small
46       amount.)  This argument is a timespec(3) structure.
47
48       If  both  fields  of  this structure are specified as 0, a poll is per‐
49       formed: sigtimedwait() returns  immediately,  either  with  information
50       about  a  signal  that  was pending for the caller, or with an error if
51       none of the signals in set was pending.
52

RETURN VALUE

54       On success, both sigwaitinfo() and sigtimedwait() return a signal  num‐
55       ber  (i.e.,  a  value greater than zero).  On failure both calls return
56       -1, with errno set to indicate the error.
57

ERRORS

59       EAGAIN No signal in set became pending within the timeout period speci‐
60              fied to sigtimedwait().
61
62       EINTR  The  wait  was  interrupted  by a signal handler; see signal(7).
63              (This handler was for a signal other than one of those in set.)
64
65       EINVAL timeout was invalid.
66

VERSIONS

68   C library/kernel differences
69       On Linux, sigwaitinfo() is a library function  implemented  on  top  of
70       sigtimedwait().
71
72       The  glibc  wrapper  functions  for  sigwaitinfo()  and  sigtimedwait()
73       silently ignore attempts to wait for the two real-time signals that are
74       used  internally by the NPTL threading implementation.  See nptl(7) for
75       details.
76
77       The original Linux system call was named sigtimedwait().  However, with
78       the  addition of real-time signals in Linux 2.2, the fixed-size, 32-bit
79       sigset_t type supported by that system call was no longer fit for  pur‐
80       pose.  Consequently, a new system call, rt_sigtimedwait(), was added to
81       support an enlarged sigset_t type.  The new system call takes a  fourth
82       argument,  size_t  sigsetsize, which specifies the size in bytes of the
83       signal set in set.  This argument is currently  required  to  have  the
84       value  sizeof(sigset_t)  (or the error EINVAL results).  The glibc sig‐
85       timedwait() wrapper function hides these details from us, transparently
86       calling rt_sigtimedwait() when the kernel provides it.
87

STANDARDS

89       POSIX.1-2008.
90

HISTORY

92       POSIX.1-2001.
93

NOTES

95       In  normal  usage,  the calling program blocks the signals in set via a
96       prior call to sigprocmask(2) (so that the default disposition for these
97       signals  does not occur if they become pending between successive calls
98       to sigwaitinfo() or sigtimedwait()) and does not establish handlers for
99       these  signals.   In  a  multithreaded  program,  the  signal should be
100       blocked in all threads, in order to prevent the  signal  being  treated
101       according  to  its  default  disposition in a thread other than the one
102       calling sigwaitinfo() or sigtimedwait()).
103
104       The set of signals that is pending for a given thread is the  union  of
105       the set of signals that is pending specifically for that thread and the
106       set of signals that is pending for the process as  a  whole  (see  sig‐
107       nal(7)).
108
109       Attempts to wait for SIGKILL and SIGSTOP are silently ignored.
110
111       If  multiple threads of a process are blocked waiting for the same sig‐
112       nal(s) in sigwaitinfo() or sigtimedwait(),  then  exactly  one  of  the
113       threads  will actually receive the signal if it becomes pending for the
114       process as a whole; which of the threads receives the signal  is  inde‐
115       terminate.
116
117       sigwaitinfo()  or sigtimedwait(), can't be used to receive signals that
118       are synchronously generated, such as the SIGSEGV  signal  that  results
119       from  accessing an invalid memory address or the SIGFPE signal that re‐
120       sults from an arithmetic error.  Such signals can be  caught  only  via
121       signal handler.
122
123       POSIX  leaves  the  meaning of a NULL value for the timeout argument of
124       sigtimedwait() unspecified, permitting the possibility  that  this  has
125       the same meaning as a call to sigwaitinfo(), and indeed this is what is
126       done on Linux.
127

SEE ALSO

129       kill(2), sigaction(2), signal(2), signalfd(2), sigpending(2),  sigproc‐
130       mask(2), sigqueue(3), sigsetops(3), sigwait(3), timespec(3), signal(7),
131       time(7)
132
133
134
135Linux man-pages 6.05              2023-03-30                    sigwaitinfo(2)
Impressum