358 lines
7.6 KiB
HTML
358 lines
7.6 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of SIGPROCMASK</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>SIGPROCMASK</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
sigprocmask, rt_sigprocmask - examine and change blocked signals
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/signal.h">signal.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<PRE>
|
|
/* Prototype for the glibc wrapper function */
|
|
<B>int sigprocmask(int </B><I>how</I><B>, const sigset_t *</B><I>set</I><B>, sigset_t *</B><I>oldset</I><B>);</B>
|
|
|
|
/* Prototype for the underlying system call */
|
|
<B>int rt_sigprocmask(int </B><I>how</I><B>, const kernel_sigset_t *</B><I>set</I><B>,</B>
|
|
<B> kernel_sigset_t *</B><I>oldset</I><B>, size_t </B><I>sigsetsize</I><B>);</B>
|
|
|
|
/* Prototype for the legacy system call (deprecated) */
|
|
<B>int sigprocmask(int </B><I>how</I><B>, const old_kernel_sigset_t *</B><I>set</I><B>,</B>
|
|
<B> old_kernel_sigset_t *</B><I>oldset</I><B>);</B><I></I>
|
|
</PRE>
|
|
|
|
<P>
|
|
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B>sigprocmask</B>():
|
|
|
|
_POSIX_C_SOURCE
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>sigprocmask</B>()
|
|
|
|
is used to fetch and/or change the signal mask of the calling thread.
|
|
The signal mask is the set of signals whose delivery is currently
|
|
blocked for the caller
|
|
(see also
|
|
<B><A HREF="/cgi-bin/man/man2html?7+signal">signal</A></B>(7)
|
|
|
|
for more details).
|
|
<P>
|
|
|
|
The behavior of the call is dependent on the value of
|
|
<I>how</I>,
|
|
|
|
as follows.
|
|
<DL COMPACT>
|
|
<DT id="1"><B>SIG_BLOCK</B>
|
|
|
|
<DD>
|
|
The set of blocked signals is the union of the current set and the
|
|
<I>set</I>
|
|
|
|
argument.
|
|
<DT id="2"><B>SIG_UNBLOCK</B>
|
|
|
|
<DD>
|
|
The signals in
|
|
<I>set</I>
|
|
|
|
are removed from the current set of blocked signals.
|
|
It is permissible to attempt to unblock a signal which is not blocked.
|
|
<DT id="3"><B>SIG_SETMASK</B>
|
|
|
|
<DD>
|
|
The set of blocked signals is set to the argument
|
|
<I>set</I>.
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
If
|
|
<I>oldset</I>
|
|
|
|
is non-NULL, the previous value of the signal mask is stored in
|
|
<I>oldset</I>.
|
|
|
|
<P>
|
|
|
|
If
|
|
<I>set</I>
|
|
|
|
is NULL, then the signal mask is unchanged (i.e.,
|
|
<I>how</I>
|
|
|
|
is ignored),
|
|
but the current value of the signal mask is nevertheless returned in
|
|
<I>oldset</I>
|
|
|
|
(if it is not NULL).
|
|
<P>
|
|
|
|
A set of functions for modifying and inspecting variables of type
|
|
<I>sigset_t</I>
|
|
|
|
("signal sets") is described in
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sigsetops">sigsetops</A></B>(3).
|
|
|
|
<P>
|
|
|
|
The use of
|
|
<B>sigprocmask</B>()
|
|
|
|
is unspecified in a multithreaded process; see
|
|
<B><A HREF="/cgi-bin/man/man2html?3+pthread_sigmask">pthread_sigmask</A></B>(3).
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
<B>sigprocmask</B>()
|
|
|
|
returns 0 on success and -1 on error.
|
|
In the event of an error,
|
|
<I>errno</I>
|
|
|
|
is set to indicate the cause.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="4"><B>EFAULT</B>
|
|
|
|
<DD>
|
|
The
|
|
<I>set</I>
|
|
|
|
or
|
|
<I>oldset</I>
|
|
|
|
argument points outside the process's allocated address space.
|
|
<DT id="5"><B>EINVAL</B>
|
|
|
|
<DD>
|
|
Either the value specified in
|
|
<I>how</I>
|
|
|
|
was invalid or the kernel does not support the size passed in
|
|
<I>sigsetsize.</I>
|
|
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
POSIX.1-2001, POSIX.1-2008.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
It is not possible to block
|
|
<B>SIGKILL</B> or <B>SIGSTOP</B>.
|
|
|
|
Attempts to do so are silently ignored.
|
|
<P>
|
|
|
|
Each of the threads in a process has its own signal mask.
|
|
<P>
|
|
|
|
A child created via
|
|
<B><A HREF="/cgi-bin/man/man2html?2+fork">fork</A></B>(2)
|
|
|
|
inherits a copy of its parent's signal mask;
|
|
the signal mask is preserved across
|
|
<B><A HREF="/cgi-bin/man/man2html?2+execve">execve</A></B>(2).
|
|
|
|
<P>
|
|
|
|
If
|
|
<B>SIGBUS</B>,
|
|
|
|
<B>SIGFPE</B>,
|
|
|
|
<B>SIGILL</B>,
|
|
|
|
or
|
|
<B>SIGSEGV</B>
|
|
|
|
are generated
|
|
while they are blocked, the result is undefined,
|
|
unless the signal was generated by
|
|
<B><A HREF="/cgi-bin/man/man2html?2+kill">kill</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sigqueue">sigqueue</A></B>(3),
|
|
|
|
or
|
|
<B><A HREF="/cgi-bin/man/man2html?3+raise">raise</A></B>(3).
|
|
|
|
<P>
|
|
|
|
See
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sigsetops">sigsetops</A></B>(3)
|
|
|
|
for details on manipulating signal sets.
|
|
<P>
|
|
|
|
Note that it is permissible (although not very useful) to specify both
|
|
<I>set</I>
|
|
|
|
and
|
|
<I>oldset</I>
|
|
|
|
as NULL.
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H3>C library/kernel differences</H3>
|
|
|
|
<P>
|
|
|
|
The kernel's definition of
|
|
<I>sigset_t</I>
|
|
|
|
differs in size from that used
|
|
by the C library.
|
|
In this manual page, the former is referred to as
|
|
<I>kernel_sigset_t</I>
|
|
|
|
(it is nevertheless named
|
|
<I>sigset_t</I>
|
|
|
|
in the kernel sources).
|
|
<P>
|
|
|
|
The glibc wrapper function for
|
|
<B>sigprocmask</B>()
|
|
|
|
silently ignores attempts to block the two real-time signals that
|
|
are used internally by the NPTL threading implementation.
|
|
See
|
|
<B><A HREF="/cgi-bin/man/man2html?7+nptl">nptl</A></B>(7)
|
|
|
|
for details.
|
|
<P>
|
|
|
|
The original Linux system call was named
|
|
<B>sigprocmask</B>().
|
|
|
|
However, with the addition of real-time signals in Linux 2.2,
|
|
the fixed-size, 32-bit
|
|
<I>sigset_t</I>
|
|
|
|
(referred to as
|
|
<I>old_kernel_sigset_t</I>
|
|
|
|
in this manual page)
|
|
type supported by that system call was no longer fit for purpose.
|
|
Consequently, a new system call,
|
|
<B>rt_sigprocmask</B>(),
|
|
|
|
was added to support an enlarged
|
|
<I>sigset_t</I>
|
|
|
|
type
|
|
(referred to as
|
|
<I>kernel_sigset_t</I>
|
|
|
|
in this manual page).
|
|
The new system call takes a fourth argument,
|
|
<I>size_t sigsetsize</I>,
|
|
|
|
which specifies the size in bytes of the signal sets in
|
|
<I>set</I>
|
|
|
|
and
|
|
<I>oldset</I>.
|
|
|
|
This argument is currently required to have a fixed architecture specific value
|
|
(equal to
|
|
<I>sizeof(kernel_sigset_t)</I>).
|
|
|
|
|
|
|
|
<P>
|
|
|
|
The glibc
|
|
<B>sigprocmask</B>()
|
|
|
|
wrapper function hides these details from us, transparently calling
|
|
<B>rt_sigprocmask</B>()
|
|
|
|
when the kernel provides it.
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+kill">kill</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+pause">pause</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+sigaction">sigaction</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+signal">signal</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+sigpending">sigpending</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+sigsuspend">sigsuspend</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+pthread_sigmask">pthread_sigmask</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sigqueue">sigqueue</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sigsetops">sigsetops</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+signal">signal</A></B>(7)
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="6"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="7"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="8"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="9"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="10"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="11"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="12"><A HREF="#lbAH">NOTES</A><DD>
|
|
<DL>
|
|
<DT id="13"><A HREF="#lbAI">C library/kernel differences</A><DD>
|
|
</DL>
|
|
<DT id="14"><A HREF="#lbAJ">SEE ALSO</A><DD>
|
|
<DT id="15"><A HREF="#lbAK">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:34 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|