1SIGWAITINFO(2)             Linux Programmer's Manual            SIGWAITINFO(2)
2
3
4

NAME

6       sigwaitinfo, sigtimedwait - synchronously wait for queued signals
7

SYNOPSIS

9       #include <signal.h>
10
11       int sigwaitinfo(const sigset_t *set, siginfo_t *info);
12
13       int sigtimedwait(const sigset_t *set, siginfo_t *info,
14                        const struct timespec *timeout);
15
16   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
17
18       sigwaitinfo(), sigtimedwait(): _POSIX_C_SOURCE >= 199309L
19

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

CONFORMING TO

67       POSIX.1-2001.
68

NOTES

70       In  normal  usage,  the calling program blocks the signals in set via a
71       prior call to sigprocmask(2) (so that the default disposition for these
72       signals  does not occur if they become pending between successive calls
73       to sigwaitinfo() or sigtimedwait()) and does not establish handlers for
74       these  signals.   In  a  multithreaded  program,  the  signal should be
75       blocked in all threads, in order to prevent the  signal  being  treated
76       according  to  its  default  disposition in a thread other than the one
77       calling sigwaitinfo() or sigtimedwait()).
78
79       The set of signals that is pending for a given thread is the  union  of
80       the set of signals that is pending specifically for that thread and the
81       set of signals that is pending for the process as  a  whole  (see  sig‐
82       nal(7)).
83
84       Attempts to wait for SIGKILL and SIGSTOP are silently ignored.
85
86       If  multiple threads of a process are blocked waiting for the same sig‐
87       nal(s) in sigwaitinfo() or sigtimedwait(),  then  exactly  one  of  the
88       threads  will actually receive the signal if it becomes pending for the
89       process as a whole; which of the threads receives the signal  is  inde‐
90       terminate.
91
92       POSIX  leaves  the  meaning of a NULL value for the timeout argument of
93       sigtimedwait() unspecified, permitting the possibility  that  this  has
94       the same meaning as a call to sigwaitinfo(), and indeed this is what is
95       done on Linux.
96
97       On Linux, sigwaitinfo() is a library function  implemented  on  top  of
98       sigtimedwait().
99

SEE ALSO

101       kill(2),  sigaction(2), signal(2), signalfd(2), sigpending(2), sigproc‐
102       mask(2), sigqueue(3), sigsetops(3), sigwait(3), signal(7), time(7)
103

COLOPHON

105       This page is part of release 3.53 of the Linux  man-pages  project.   A
106       description  of  the project, and information about reporting bugs, can
107       be found at http://www.kernel.org/doc/man-pages/.
108
109
110
111Linux                             2012-07-21                    SIGWAITINFO(2)
Impressum