]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/sigprocmask.2
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man2 / sigprocmask.2
CommitLineData
7ff599e2 1.\" Copyright (c) 2005 Michael Kerrisk
c13182ef 2.\" based on earlier work by faith@cs.unc.edu and
7ff599e2
MK
3.\" Mike Battersby <mib@deakin.edu.au>
4.\"
5fbde956 5.\" SPDX-License-Identifier: Linux-man-pages-copyleft
7ff599e2
MK
6.\"
7.\" 2005-09-15, mtk, Created new page by splitting off from sigaction.2
8.\"
45186a5d 9.TH SIGPROCMASK 2 2021-03-22 "Linux man-pages (unreleased)"
7ff599e2 10.SH NAME
166b65db 11sigprocmask, rt_sigprocmask \- examine and change blocked signals
bc57a2c9
AC
12.SH LIBRARY
13Standard C library
8fc3b2cf 14.RI ( libc ", " \-lc )
7ff599e2
MK
15.SH SYNOPSIS
16.B #include <signal.h>
68e4db0a 17.PP
86d5ed87
KF
18.nf
19/* Prototype for the glibc wrapper function */
1c227750
AC
20.BI "int sigprocmask(int " how ", const sigset_t *restrict " set ,
21.BI " sigset_t *restrict " oldset );
dbfe9c70 22.PP
1b4d275a
AC
23.BR "#include <signal.h>" " /* Definition of " SIG_* " constants */"
24.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
25.B #include <unistd.h>
26.PP
86d5ed87 27/* Prototype for the underlying system call */
1b4d275a 28.BI "int syscall(SYS_rt_sigprocmask, int " how ", const kernel_sigset_t *" set ,
f2667a72 29.BI " kernel_sigset_t *" oldset ", size_t " sigsetsize );
dbfe9c70 30.PP
86d5ed87 31/* Prototype for the legacy system call (deprecated) */
1b4d275a 32.BI "int syscall(SYS_sigprocmask, int " how ", const old_kernel_sigset_t *" set ,
9bfc9cb1 33.BI " old_kernel_sigset_t *" oldset );
86d5ed87 34.fi
68e4db0a 35.PP
d39ad78f 36.RS -4
0f200f07
MK
37Feature Test Macro Requirements for glibc (see
38.BR feature_test_macros (7)):
d39ad78f 39.RE
68e4db0a 40.PP
0f200f07 41.BR sigprocmask ():
9d2adbae
MK
42.nf
43 _POSIX_C_SOURCE
44.fi
7ff599e2
MK
45.SH DESCRIPTION
46.BR sigprocmask ()
92ae3965
MK
47is used to fetch and/or change the signal mask of the calling thread.
48The signal mask is the set of signals whose delivery is currently
49blocked for the caller
4c5bcd47
MK
50(see also
51.BR signal (7)
52for more details).
efeece04 53.PP
d9bfdb9c 54The behavior of the call is dependent on the value of
7ff599e2
MK
55.IR how ,
56as follows.
7ff599e2
MK
57.TP
58.B SIG_BLOCK
59The set of blocked signals is the union of the current set and the
60.I set
61argument.
62.TP
63.B SIG_UNBLOCK
64The signals in
65.I set
c13182ef 66are removed from the current set of blocked signals.
e935e108 67It is permissible to attempt to unblock a signal which is not blocked.
7ff599e2
MK
68.TP
69.B SIG_SETMASK
70The set of blocked signals is set to the argument
71.IR set .
7ff599e2
MK
72.PP
73If
74.I oldset
f38d8f71 75is non-NULL, the previous value of the signal mask is stored in
7ff599e2 76.IR oldset .
efeece04 77.PP
7ff599e2
MK
78If
79.I set
80is NULL, then the signal mask is unchanged (i.e.,
81.I how
82is ignored),
83but the current value of the signal mask is nevertheless returned in
0daa9e92 84.I oldset
53e67125 85(if it is not NULL).
efeece04 86.PP
35acdc5d
MK
87A set of functions for modifying and inspecting variables of type
88.I sigset_t
89("signal sets") is described in
90.BR sigsetops (3).
efeece04 91.PP
7ff599e2
MK
92The use of
93.BR sigprocmask ()
94is unspecified in a multithreaded process; see
95.BR pthread_sigmask (3).
47297adb 96.SH RETURN VALUE
7ff599e2 97.BR sigprocmask ()
cb6a894e
MK
98returns 0 on success.
99On failure, \-1 is returned and
2cbd0ac5 100.I errno
cb6a894e 101is set to indicate the error.
7ff599e2 102.SH ERRORS
ef301293
MF
103.TP
104.B EFAULT
57713dca 105The
ef301293
MF
106.I set
107or
108.I oldset
109argument points outside the process's allocated address space.
110.TP
7ff599e2 111.B EINVAL
86d5ed87 112Either the value specified in
7ff599e2 113.I how
86d5ed87
KF
114was invalid or the kernel does not support the size passed in
115.I sigsetsize.
3113c7f3 116.SH STANDARDS
2b724927 117POSIX.1-2001, POSIX.1-2008.
7ff599e2 118.SH NOTES
c13182ef 119It is not possible to block
7ff599e2
MK
120.BR SIGKILL " or " SIGSTOP .
121Attempts to do so are silently ignored.
efeece04 122.PP
92ae3965 123Each of the threads in a process has its own signal mask.
efeece04 124.PP
eebf482d
MK
125A child created via
126.BR fork (2)
127inherits a copy of its parent's signal mask;
128the signal mask is preserved across
129.BR execve (2).
efeece04 130.PP
7ff599e2
MK
131If
132.BR SIGBUS ,
c13182ef 133.BR SIGFPE ,
7ff599e2
MK
134.BR SIGILL ,
135or
0daa9e92 136.B SIGSEGV
7ff599e2
MK
137are generated
138while they are blocked, the result is undefined,
736bedf6 139unless the signal was generated by
7ff599e2 140.BR kill (2),
485ab701 141.BR sigqueue (3),
7ff599e2
MK
142or
143.BR raise (3).
144.PP
145See
146.BR sigsetops (3)
147for details on manipulating signal sets.
efeece04 148.PP
b9ad845d
MK
149Note that it is permissible (although not very useful) to specify both
150.I set
151and
152.I oldset
153as NULL.
166b65db 154.\"
0722a578 155.SS C library/kernel differences
86d5ed87 156The kernel's definition of
1ae6b2c7 157.I sigset_t
86d5ed87 158differs in size from that used
6c79a020
MK
159by the C library.
160In this manual page, the former is referred to as
86d5ed87 161.I kernel_sigset_t
6c79a020 162(it is nevertheless named
86d5ed87
KF
163.I sigset_t
164in the kernel sources).
efeece04 165.PP
3699b154
MK
166The glibc wrapper function for
167.BR sigprocmask ()
168silently ignores attempts to block the two real-time signals that
169are used internally by the NPTL threading implementation.
170See
171.BR nptl (7)
172for details.
efeece04 173.PP
166b65db
MK
174The original Linux system call was named
175.BR sigprocmask ().
176However, with the addition of real-time signals in Linux 2.2,
177the fixed-size, 32-bit
1ae6b2c7 178.I sigset_t
86d5ed87 179(referred to as
1ae6b2c7 180.I old_kernel_sigset_t
6c79a020 181in this manual page)
166b65db
MK
182type supported by that system call was no longer fit for purpose.
183Consequently, a new system call,
184.BR rt_sigprocmask (),
185was added to support an enlarged
1ae6b2c7 186.I sigset_t
86d5ed87
KF
187type
188(referred to as
1ae6b2c7 189.I kernel_sigset_t
6c79a020 190in this manual page).
166b65db
MK
191The new system call takes a fourth argument,
192.IR "size_t sigsetsize" ,
193which specifies the size in bytes of the signal sets in
1ae6b2c7 194.I set
166b65db
MK
195and
196.IR oldset .
ad8c02ab
DL
197This argument is currently required to have a fixed architecture specific value
198(equal to
199.IR sizeof(kernel_sigset_t) ).
200.\" sizeof(kernel_sigset_t) == _NSIG / 8,
201.\" which equals to 8 on most architectures, but e.g. on MIPS it's 16.
efeece04 202.PP
166b65db
MK
203The glibc
204.BR sigprocmask ()
205wrapper function hides these details from us, transparently calling
206.BR rt_sigprocmask ()
207when the kernel provides it.
208.\"
47297adb 209.SH SEE ALSO
7ff599e2
MK
210.BR kill (2),
211.BR pause (2),
212.BR sigaction (2),
213.BR signal (2),
214.BR sigpending (2),
7ff599e2
MK
215.BR sigsuspend (2),
216.BR pthread_sigmask (3),
485ab701 217.BR sigqueue (3),
7ff599e2
MK
218.BR sigsetops (3),
219.BR signal (7)