pipe.2: SEE ALSO: add tee(2) and vmsplice(2)
[man-pages.git] / man2 / sigprocmask.2
blob91b01a71b2286f5baa11369f411a4f567ceabe9a
1 .\" Copyright (c) 2005 Michael Kerrisk
2 .\" based on earlier work by faith@cs.unc.edu and
3 .\" Mike Battersby <mib@deakin.edu.au>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .\" 2005-09-15, mtk, Created new page by splitting off from sigaction.2
28 .\"
29 .TH SIGPROCMASK 2 2017-05-03 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 sigprocmask, rt_sigprocmask \- examine and change blocked signals
32 .SH SYNOPSIS
33 .B #include <signal.h>
34 .sp
35 .nf
36 /* Prototype for the glibc wrapper function */
37 .BI "int sigprocmask(int " how ", const sigset_t *" set ", sigset_t *" oldset );
39 /* Prototype for the underlying system call */
40 .BI "int rt_sigprocmask(int " how ", const kernel_sigset_t *" set ,
41 .BI "                   kernel_sigset_t *" oldset ", size_t " sigsetsize );
43 /* Prototype for the legacy system call (deprecated) */
44 .BI "int sigprocmask(int " how ", const old_kernel_sigset_t *" set ,
45 .BI "                old_kernel_sigset_t *" oldset ); "
46 .fi
48 .sp
49 .in -4n
50 Feature Test Macro Requirements for glibc (see
51 .BR feature_test_macros (7)):
52 .in
53 .sp
54 .ad l
55 .BR sigprocmask ():
56 _POSIX_C_SOURCE
57 .ad b
58 .SH DESCRIPTION
59 .BR sigprocmask ()
60 is used to fetch and/or change the signal mask of the calling thread.
61 The signal mask is the set of signals whose delivery is currently
62 blocked for the caller
63 (see also
64 .BR signal (7)
65 for more details).
67 The behavior of the call is dependent on the value of
68 .IR how ,
69 as follows.
70 .TP
71 .B SIG_BLOCK
72 The set of blocked signals is the union of the current set and the
73 .I set
74 argument.
75 .TP
76 .B SIG_UNBLOCK
77 The signals in
78 .I set
79 are removed from the current set of blocked signals.
80 It is permissible to attempt to unblock a signal which is not blocked.
81 .TP
82 .B SIG_SETMASK
83 The set of blocked signals is set to the argument
84 .IR set .
85 .PP
87 .I oldset
88 is non-NULL, the previous value of the signal mask is stored in
89 .IR oldset .
92 .I set
93 is NULL, then the signal mask is unchanged (i.e.,
94 .I how
95 is ignored),
96 but the current value of the signal mask is nevertheless returned in
97 .I oldset
98 (if it is not NULL).
100 A set of functions for modifying and inspecting variables of type
101 .I sigset_t
102 ("signal sets") is described in
103 .BR sigsetops (3).
105 The use of
106 .BR sigprocmask ()
107 is unspecified in a multithreaded process; see
108 .BR pthread_sigmask (3).
109 .SH RETURN VALUE
110 .BR sigprocmask ()
111 returns 0 on success and \-1 on error.
112 In the event of an error,
113 .I errno
114 is set to indicate the cause.
115 .SH ERRORS
117 .B EFAULT
119 .I set
121 .I oldset
122 argument points outside the process's allocated address space.
124 .B EINVAL
125 Either the value specified in
126 .I how
127 was invalid or the kernel does not support the size passed in
128 .I sigsetsize.
129 .SH CONFORMING TO
130 POSIX.1-2001, POSIX.1-2008.
131 .SH NOTES
132 It is not possible to block
133 .BR SIGKILL " or " SIGSTOP .
134 Attempts to do so are silently ignored.
136 Each of the threads in a process has its own signal mask.
138 A child created via
139 .BR fork (2)
140 inherits a copy of its parent's signal mask;
141 the signal mask is preserved across
142 .BR execve (2).
145 .BR SIGBUS ,
146 .BR SIGFPE ,
147 .BR SIGILL ,
149 .B SIGSEGV
150 are generated
151 while they are blocked, the result is undefined,
152 unless the signal was generated by
153 .BR kill (2),
154 .BR sigqueue (3),
156 .BR raise (3).
159 .BR sigsetops (3)
160 for details on manipulating signal sets.
162 Note that it is permissible (although not very useful) to specify both
163 .I set
165 .I oldset
166 as NULL.
168 .SS C library/kernel differences
170 The kernel's definition of
171 .IR sigset_t
172 differs in size from that used
173 by the C library.
174 In this manual page, the former is referred to as
175 .I kernel_sigset_t
176 (it is nevertheless named
177 .I sigset_t
178 in the kernel sources).
180 The glibc wrapper function for
181 .BR sigprocmask ()
182 silently ignores attempts to block the two real-time signals that
183 are used internally by the NPTL threading implementation.
185 .BR nptl (7)
186 for details.
188 The original Linux system call was named
189 .BR sigprocmask ().
190 However, with the addition of real-time signals in Linux 2.2,
191 the fixed-size, 32-bit
192 .IR sigset_t
193 (referred to as
194 .IR old_kernel_sigset_t
195 in this manual page)
196 type supported by that system call was no longer fit for purpose.
197 Consequently, a new system call,
198 .BR rt_sigprocmask (),
199 was added to support an enlarged
200 .IR sigset_t
201 type
202 (referred to as
203 .IR kernel_sigset_t
204 in this manual page).
205 The new system call takes a fourth argument,
206 .IR "size_t sigsetsize" ,
207 which specifies the size in bytes of the signal sets in
208 .IR set
210 .IR oldset .
211 This argument is currently required to have a fixed architecture specific value
212 (equal to
213 .IR sizeof(kernel_sigset_t) ).
214 .\" sizeof(kernel_sigset_t) == _NSIG / 8,
215 .\" which equals to 8 on most architectures, but e.g. on MIPS it's 16.
217 The glibc
218 .BR sigprocmask ()
219 wrapper function hides these details from us, transparently calling
220 .BR rt_sigprocmask ()
221 when the kernel provides it.
223 .SH SEE ALSO
224 .BR kill (2),
225 .BR pause (2),
226 .BR sigaction (2),
227 .BR signal (2),
228 .BR sigpending (2),
229 .BR sigsuspend (2),
230 .BR pthread_sigmask (3),
231 .BR sigqueue (3),
232 .BR sigsetops (3),
233 .BR signal (7)