|
Packit |
7cfc04 |
.\" Copyright (c) 2002 Michael Kerrisk <mtk.manpages@gmail.com>
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_START(VERBATIM)
|
|
Packit |
7cfc04 |
.\" Permission is granted to make and distribute verbatim copies of this
|
|
Packit |
7cfc04 |
.\" manual provided the copyright notice and this permission notice are
|
|
Packit |
7cfc04 |
.\" preserved on all copies.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Permission is granted to copy and distribute modified versions of this
|
|
Packit |
7cfc04 |
.\" manual under the conditions for verbatim copying, provided that the
|
|
Packit |
7cfc04 |
.\" entire resulting derived work is distributed under the terms of a
|
|
Packit |
7cfc04 |
.\" permission notice identical to this one.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
Packit |
7cfc04 |
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
Packit |
7cfc04 |
.\" responsibility for errors or omissions, or for damages resulting from
|
|
Packit |
7cfc04 |
.\" the use of the information contained herein. The author(s) may not
|
|
Packit |
7cfc04 |
.\" have taken the same level of care in the production of this manual,
|
|
Packit |
7cfc04 |
.\" which is licensed free of charge, as they might when working
|
|
Packit |
7cfc04 |
.\" professionally.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
Packit |
7cfc04 |
.\" the source, must acknowledge the copyright and authors of this work.
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_END
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.TH SIGWAITINFO 2 2017-09-15 "Linux" "Linux Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
sigwaitinfo, sigtimedwait, rt_sigtimedwait \- synchronously wait
|
|
Packit |
7cfc04 |
for queued signals
|
|
Packit |
7cfc04 |
.SH SYNOPSIS
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
.B #include <signal.h>
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BI "int sigwaitinfo(const sigset_t *" set ", siginfo_t *" info ");"
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BI "int sigtimedwait(const sigset_t *" set ", siginfo_t *" info ", "
|
|
Packit |
7cfc04 |
.BI " const struct timespec *" timeout ");"
|
|
Packit |
7cfc04 |
.fi
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.in -4n
|
|
Packit |
7cfc04 |
Feature Test Macro Requirements for glibc (see
|
|
Packit |
7cfc04 |
.BR feature_test_macros (7)):
|
|
Packit |
7cfc04 |
.in
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BR sigwaitinfo (),
|
|
Packit |
7cfc04 |
.BR sigtimedwait ():
|
|
Packit |
7cfc04 |
_POSIX_C_SOURCE\ >=\ 199309L
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
.BR sigwaitinfo ()
|
|
Packit |
7cfc04 |
suspends execution of the calling thread until one of the signals in
|
|
Packit |
7cfc04 |
.I set
|
|
Packit |
7cfc04 |
is pending
|
|
Packit |
7cfc04 |
(If one of the signals in
|
|
Packit |
7cfc04 |
.I set
|
|
Packit |
7cfc04 |
is already pending for the calling thread,
|
|
Packit |
7cfc04 |
.BR sigwaitinfo ()
|
|
Packit |
7cfc04 |
will return immediately.)
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BR sigwaitinfo ()
|
|
Packit |
7cfc04 |
removes the signal from the set of pending
|
|
Packit |
7cfc04 |
signals and returns the signal number as its function result.
|
|
Packit |
7cfc04 |
If the
|
|
Packit |
7cfc04 |
.I info
|
|
Packit |
7cfc04 |
argument is not NULL,
|
|
Packit |
7cfc04 |
then the buffer that it points to is used to return a structure of type
|
|
Packit |
7cfc04 |
.I siginfo_t
|
|
Packit |
7cfc04 |
(see
|
|
Packit |
7cfc04 |
.BR sigaction (2))
|
|
Packit |
7cfc04 |
containing information about the signal.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If multiple signals in
|
|
Packit |
7cfc04 |
.I set
|
|
Packit |
7cfc04 |
are pending for the caller, the signal that is retrieved by
|
|
Packit |
7cfc04 |
.BR sigwaitinfo ()
|
|
Packit |
7cfc04 |
is determined according to the usual ordering rules; see
|
|
Packit |
7cfc04 |
.BR signal (7)
|
|
Packit |
7cfc04 |
for further details.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BR sigtimedwait ()
|
|
Packit |
7cfc04 |
operates in exactly the same way as
|
|
Packit |
7cfc04 |
.BR sigwaitinfo ()
|
|
Packit |
7cfc04 |
except that it has an additional argument,
|
|
Packit |
7cfc04 |
.IR timeout ,
|
|
Packit |
7cfc04 |
which specifies the interval for which
|
|
Packit |
7cfc04 |
the thread is suspended waiting for a signal.
|
|
Packit |
7cfc04 |
(This interval will be rounded up to the system clock granularity,
|
|
Packit |
7cfc04 |
and kernel scheduling delays mean that the interval
|
|
Packit |
7cfc04 |
may overrun by a small amount.)
|
|
Packit |
7cfc04 |
This argument is of the following type:
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.in +4n
|
|
Packit |
7cfc04 |
.EX
|
|
Packit |
7cfc04 |
struct timespec {
|
|
Packit |
7cfc04 |
long tv_sec; /* seconds */
|
|
Packit |
7cfc04 |
long tv_nsec; /* nanoseconds */
|
|
Packit |
7cfc04 |
}
|
|
Packit |
7cfc04 |
.EE
|
|
Packit |
7cfc04 |
.in
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If both fields of this structure are specified as 0, a poll is performed:
|
|
Packit |
7cfc04 |
.BR sigtimedwait ()
|
|
Packit |
7cfc04 |
returns immediately, either with information about a signal that
|
|
Packit |
7cfc04 |
was pending for the caller, or with an error
|
|
Packit |
7cfc04 |
if none of the signals in
|
|
Packit |
7cfc04 |
.I set
|
|
Packit |
7cfc04 |
was pending.
|
|
Packit |
7cfc04 |
.SH RETURN VALUE
|
|
Packit |
7cfc04 |
On success, both
|
|
Packit |
7cfc04 |
.BR sigwaitinfo ()
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR sigtimedwait ()
|
|
Packit |
7cfc04 |
return a signal number (i.e., a value greater than zero).
|
|
Packit |
7cfc04 |
On failure both calls return \-1, with
|
|
Packit |
7cfc04 |
.I errno
|
|
Packit |
7cfc04 |
set to indicate the error.
|
|
Packit |
7cfc04 |
.SH ERRORS
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B EAGAIN
|
|
Packit |
7cfc04 |
No signal in
|
|
Packit |
7cfc04 |
.I set
|
|
Packit |
7cfc04 |
was became pending within the
|
|
Packit |
7cfc04 |
.I timeout
|
|
Packit |
7cfc04 |
period specified to
|
|
Packit |
7cfc04 |
.BR sigtimedwait ().
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B EINTR
|
|
Packit |
7cfc04 |
The wait was interrupted by a signal handler; see
|
|
Packit |
7cfc04 |
.BR signal (7).
|
|
Packit |
7cfc04 |
(This handler was for a signal other than one of those in
|
|
Packit |
7cfc04 |
.IR set .)
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B EINVAL
|
|
Packit |
7cfc04 |
.I timeout
|
|
Packit |
7cfc04 |
was invalid.
|
|
Packit |
7cfc04 |
.SH CONFORMING TO
|
|
Packit |
7cfc04 |
POSIX.1-2001, POSIX.1-2008.
|
|
Packit |
7cfc04 |
.SH NOTES
|
|
Packit |
7cfc04 |
In normal usage, the calling program blocks the signals in
|
|
Packit |
7cfc04 |
.I set
|
|
Packit |
7cfc04 |
via a prior call to
|
|
Packit |
7cfc04 |
.BR sigprocmask (2)
|
|
Packit |
7cfc04 |
(so that the default disposition for these signals does not occur if they
|
|
Packit |
7cfc04 |
become pending between successive calls to
|
|
Packit |
7cfc04 |
.BR sigwaitinfo ()
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.BR sigtimedwait ())
|
|
Packit |
7cfc04 |
and does not establish handlers for these signals.
|
|
Packit |
7cfc04 |
In a multithreaded program,
|
|
Packit |
7cfc04 |
the signal should be blocked in all threads, in order to prevent
|
|
Packit |
7cfc04 |
the signal being treated according to its default disposition in
|
|
Packit |
7cfc04 |
a thread other than the one calling
|
|
Packit |
7cfc04 |
.BR sigwaitinfo ()
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.BR sigtimedwait ()).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The set of signals that is pending for a given thread is the
|
|
Packit |
7cfc04 |
union of the set of signals that is pending specifically for that thread
|
|
Packit |
7cfc04 |
and the set of signals that is pending for the process as a whole (see
|
|
Packit |
7cfc04 |
.BR signal (7)).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Attempts to wait for
|
|
Packit |
7cfc04 |
.B SIGKILL
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.B SIGSTOP
|
|
Packit |
7cfc04 |
are silently ignored.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If multiple threads of a process are blocked
|
|
Packit |
7cfc04 |
waiting for the same signal(s) in
|
|
Packit |
7cfc04 |
.BR sigwaitinfo ()
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.BR sigtimedwait (),
|
|
Packit |
7cfc04 |
then exactly one of the threads will actually receive the
|
|
Packit |
7cfc04 |
signal if it becomes pending for the process as a whole;
|
|
Packit |
7cfc04 |
which of the threads receives the signal is indeterminate.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BR sigwaitinfo ()
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.BR sigtimedwait (),
|
|
Packit |
7cfc04 |
can't be used to receive signals that
|
|
Packit |
7cfc04 |
are synchronously generated, such as the
|
|
Packit |
7cfc04 |
.BR SIGSEGV
|
|
Packit |
7cfc04 |
signal that results from accessing an invalid memory address
|
|
Packit |
7cfc04 |
or the
|
|
Packit |
7cfc04 |
.BR SIGFPE
|
|
Packit |
7cfc04 |
signal that results from an arithmetic error.
|
|
Packit |
7cfc04 |
Such signals can be caught only via signal handler.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
POSIX leaves the meaning of a NULL value for the
|
|
Packit |
7cfc04 |
.I timeout
|
|
Packit |
7cfc04 |
argument of
|
|
Packit |
7cfc04 |
.BR sigtimedwait ()
|
|
Packit |
7cfc04 |
unspecified, permitting the possibility that this has the same meaning
|
|
Packit |
7cfc04 |
as a call to
|
|
Packit |
7cfc04 |
.BR sigwaitinfo (),
|
|
Packit |
7cfc04 |
and indeed this is what is done on Linux.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.SS C library/kernel differences
|
|
Packit |
7cfc04 |
On Linux,
|
|
Packit |
7cfc04 |
.BR sigwaitinfo ()
|
|
Packit |
7cfc04 |
is a library function implemented on top of
|
|
Packit |
7cfc04 |
.BR sigtimedwait ().
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The glibc wrapper functions for
|
|
Packit |
7cfc04 |
.BR sigwaitinfo ()
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR sigtimedwait ()
|
|
Packit |
7cfc04 |
silently ignore attempts to wait for the two real-time signals that
|
|
Packit |
7cfc04 |
are used internally by the NPTL threading implementation.
|
|
Packit |
7cfc04 |
See
|
|
Packit |
7cfc04 |
.BR nptl (7)
|
|
Packit |
7cfc04 |
for details.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The original Linux system call was named
|
|
Packit |
7cfc04 |
.BR sigtimedwait ().
|
|
Packit |
7cfc04 |
However, with the addition of real-time signals in Linux 2.2,
|
|
Packit |
7cfc04 |
the fixed-size, 32-bit
|
|
Packit |
7cfc04 |
.I sigset_t
|
|
Packit |
7cfc04 |
type supported by that system call was no longer fit for purpose.
|
|
Packit |
7cfc04 |
Consequently, a new system call,
|
|
Packit |
7cfc04 |
.BR rt_sigtimedwait (),
|
|
Packit |
7cfc04 |
was added to support an enlarged
|
|
Packit |
7cfc04 |
.IR sigset_t
|
|
Packit |
7cfc04 |
type.
|
|
Packit |
7cfc04 |
The new system call takes a fourth argument,
|
|
Packit |
7cfc04 |
.IR "size_t sigsetsize" ,
|
|
Packit |
7cfc04 |
which specifies the size in bytes of the signal set in
|
|
Packit |
7cfc04 |
.IR set .
|
|
Packit |
7cfc04 |
This argument is currently required to have the value
|
|
Packit |
7cfc04 |
.IR sizeof(sigset_t)
|
|
Packit |
7cfc04 |
(or the error
|
|
Packit |
7cfc04 |
.B EINVAL
|
|
Packit |
7cfc04 |
results).
|
|
Packit |
7cfc04 |
The glibc
|
|
Packit |
7cfc04 |
.BR sigtimedwait ()
|
|
Packit |
7cfc04 |
wrapper function hides these details from us, transparently calling
|
|
Packit |
7cfc04 |
.BR rt_sigtimedwait ()
|
|
Packit |
7cfc04 |
when the kernel provides it.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.SH SEE ALSO
|
|
Packit |
7cfc04 |
.BR kill (2),
|
|
Packit |
7cfc04 |
.BR sigaction (2),
|
|
Packit |
7cfc04 |
.BR signal (2),
|
|
Packit |
7cfc04 |
.BR signalfd (2),
|
|
Packit |
7cfc04 |
.BR sigpending (2),
|
|
Packit |
7cfc04 |
.BR sigprocmask (2),
|
|
Packit |
7cfc04 |
.BR sigqueue (3),
|
|
Packit |
7cfc04 |
.BR sigsetops (3),
|
|
Packit |
7cfc04 |
.BR sigwait (3),
|
|
Packit |
7cfc04 |
.BR signal (7),
|
|
Packit |
7cfc04 |
.BR time (7)
|
|
Packit |
7cfc04 |
.SH COLOPHON
|
|
Packit |
7cfc04 |
This page is part of release 4.15 of the Linux
|
|
Packit |
7cfc04 |
.I man-pages
|
|
Packit |
7cfc04 |
project.
|
|
Packit |
7cfc04 |
A description of the project,
|
|
Packit |
7cfc04 |
information about reporting bugs,
|
|
Packit |
7cfc04 |
and the latest version of this page,
|
|
Packit |
7cfc04 |
can be found at
|
|
Packit |
7cfc04 |
\%https://www.kernel.org/doc/man\-pages/.
|