Blame man2/sigsuspend.2

Packit 7cfc04
.\" Copyright (c) 2005 Michael Kerrisk
Packit 7cfc04
.\" based on earlier work by faith@cs.unc.edu and
Packit 7cfc04
.\" Mike Battersby <mib@deakin.edu.au>
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
.\" 2005-09-15, mtk, Created new page by splitting off from sigaction.2
Packit 7cfc04
.\"
Packit 7cfc04
.TH SIGSUSPEND 2 2017-09-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
sigsuspend, rt_sigsuspend \- wait for a signal
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.B #include <signal.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int sigsuspend(const sigset_t *" mask );
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
.ad l
Packit 7cfc04
.BR sigsuspend ():
Packit 7cfc04
_POSIX_C_SOURCE
Packit 7cfc04
.ad b
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
.BR sigsuspend ()
Packit 7cfc04
temporarily replaces the signal mask of the calling process with the
Packit 7cfc04
mask given by
Packit 7cfc04
.I mask
Packit 7cfc04
and then suspends the process until delivery of a signal whose
Packit 7cfc04
action is to invoke a signal handler or to terminate a process.
Packit 7cfc04
.PP
Packit 7cfc04
If the signal terminates the process, then
Packit 7cfc04
.BR sigsuspend ()
Packit 7cfc04
does not return.
Packit 7cfc04
If the signal is caught, then
Packit 7cfc04
.BR sigsuspend ()
Packit 7cfc04
returns after the signal handler returns,
Packit 7cfc04
and the signal mask is restored to the state before the call to
Packit 7cfc04
.BR sigsuspend ().
Packit 7cfc04
.PP
Packit 7cfc04
It is not possible to block
Packit 7cfc04
.B SIGKILL
Packit 7cfc04
or
Packit 7cfc04
.BR SIGSTOP ;
Packit 7cfc04
specifying these signals in
Packit 7cfc04
.IR mask ,
Packit 7cfc04
has no effect on the process's signal mask.
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
.BR sigsuspend ()
Packit 7cfc04
always returns \-1, with
Packit 7cfc04
.I errno
Packit 7cfc04
set to indicate the error (normally,
Packit 7cfc04
.BR EINTR ).
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EFAULT
Packit 7cfc04
.I mask
Packit 7cfc04
points to memory which is not a valid part of the process address space.
Packit 7cfc04
.TP
Packit 7cfc04
.B EINTR
Packit 7cfc04
The call was interrupted by a signal;
Packit 7cfc04
.BR signal (7).
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
POSIX.1-2001, POSIX.1-2008.
Packit 7cfc04
.SH NOTES
Packit 7cfc04
.PP
Packit 7cfc04
Normally,
Packit 7cfc04
.BR sigsuspend ()
Packit 7cfc04
is used in conjunction with
Packit 7cfc04
.BR sigprocmask (2)
Packit 7cfc04
in order to prevent delivery of a signal during the execution of a
Packit 7cfc04
critical code section.
Packit 7cfc04
The caller first blocks the signals with
Packit 7cfc04
.BR sigprocmask (2).
Packit 7cfc04
When the critical code has completed, the caller then waits for the
Packit 7cfc04
signals by calling
Packit 7cfc04
.BR sigsuspend ()
Packit 7cfc04
with the signal mask that was returned by
Packit 7cfc04
.BR sigprocmask (2)
Packit 7cfc04
(in the
Packit 7cfc04
.I oldset
Packit 7cfc04
argument).
Packit 7cfc04
.PP
Packit 7cfc04
See
Packit 7cfc04
.BR sigsetops (3)
Packit 7cfc04
for details on manipulating signal sets.
Packit 7cfc04
.\"
Packit 7cfc04
.SS C library/kernel differences
Packit 7cfc04
The original Linux system call was named
Packit 7cfc04
.BR sigsuspend ().
Packit 7cfc04
However, with the addition of real-time signals in Linux 2.2,
Packit 7cfc04
the fixed-size, 32-bit
Packit 7cfc04
.IR 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_sigsuspend (),
Packit 7cfc04
was added to support an enlarged
Packit 7cfc04
.IR sigset_t
Packit 7cfc04
type.
Packit 7cfc04
The new system call takes a second argument,
Packit 7cfc04
.IR "size_t sigsetsize" ,
Packit 7cfc04
which specifies the size in bytes of the signal set in
Packit 7cfc04
.IR mask .
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 sigsuspend ()
Packit 7cfc04
wrapper function hides these details from us, transparently calling
Packit 7cfc04
.BR rt_sigsuspend ()
Packit 7cfc04
when the kernel provides it.
Packit 7cfc04
.\"
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR kill (2),
Packit 7cfc04
.BR pause (2),
Packit 7cfc04
.BR sigaction (2),
Packit 7cfc04
.BR signal (2),
Packit 7cfc04
.BR sigprocmask (2),
Packit 7cfc04
.BR sigwaitinfo (2),
Packit 7cfc04
.BR sigsetops (3),
Packit 7cfc04
.BR sigwait (3),
Packit 7cfc04
.BR signal (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/.