]>
Commit | Line | Data |
---|---|---|
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 | .\" | |
93015253 | 5 | .\" %%%LICENSE_START(VERBATIM) |
7ff599e2 MK |
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. | |
c13182ef | 14 | .\" |
7ff599e2 MK |
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. | |
c13182ef | 22 | .\" |
7ff599e2 MK |
23 | .\" Formatted or processed versions of this manual, if unaccompanied by |
24 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 25 | .\" %%%LICENSE_END |
7ff599e2 MK |
26 | .\" |
27 | .\" 2005-09-15, mtk, Created new page by splitting off from sigaction.2 | |
28 | .\" | |
4b8c67d9 | 29 | .TH SIGPROCMASK 2 2017-09-15 "Linux" "Linux Programmer's Manual" |
7ff599e2 | 30 | .SH NAME |
166b65db | 31 | sigprocmask, rt_sigprocmask \- examine and change blocked signals |
7ff599e2 MK |
32 | .SH SYNOPSIS |
33 | .B #include <signal.h> | |
68e4db0a | 34 | .PP |
86d5ed87 KF |
35 | .nf |
36 | /* Prototype for the glibc wrapper function */ | |
37 | .BI "int sigprocmask(int " how ", const sigset_t *" set ", sigset_t *" oldset ); | |
dbfe9c70 | 38 | .PP |
86d5ed87 KF |
39 | /* Prototype for the underlying system call */ |
40 | .BI "int rt_sigprocmask(int " how ", const kernel_sigset_t *" set , | |
96580790 | 41 | .BI " kernel_sigset_t *" oldset ", size_t " sigsetsize ); |
dbfe9c70 | 42 | .PP |
86d5ed87 KF |
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 | |
68e4db0a | 47 | .PP |
0f200f07 MK |
48 | .in -4n |
49 | Feature Test Macro Requirements for glibc (see | |
50 | .BR feature_test_macros (7)): | |
51 | .in | |
68e4db0a | 52 | .PP |
0f200f07 MK |
53 | .ad l |
54 | .BR sigprocmask (): | |
cff459de | 55 | _POSIX_C_SOURCE |
0f200f07 | 56 | .ad b |
7ff599e2 MK |
57 | .SH DESCRIPTION |
58 | .BR sigprocmask () | |
92ae3965 MK |
59 | is used to fetch and/or change the signal mask of the calling thread. |
60 | The signal mask is the set of signals whose delivery is currently | |
61 | blocked for the caller | |
4c5bcd47 MK |
62 | (see also |
63 | .BR signal (7) | |
64 | for more details). | |
efeece04 | 65 | .PP |
d9bfdb9c | 66 | The behavior of the call is dependent on the value of |
7ff599e2 MK |
67 | .IR how , |
68 | as follows. | |
7ff599e2 MK |
69 | .TP |
70 | .B SIG_BLOCK | |
71 | The set of blocked signals is the union of the current set and the | |
72 | .I set | |
73 | argument. | |
74 | .TP | |
75 | .B SIG_UNBLOCK | |
76 | The signals in | |
77 | .I set | |
c13182ef | 78 | are removed from the current set of blocked signals. |
e935e108 | 79 | It is permissible to attempt to unblock a signal which is not blocked. |
7ff599e2 MK |
80 | .TP |
81 | .B SIG_SETMASK | |
82 | The set of blocked signals is set to the argument | |
83 | .IR set . | |
7ff599e2 MK |
84 | .PP |
85 | If | |
86 | .I oldset | |
f38d8f71 | 87 | is non-NULL, the previous value of the signal mask is stored in |
7ff599e2 | 88 | .IR oldset . |
efeece04 | 89 | .PP |
7ff599e2 MK |
90 | If |
91 | .I set | |
92 | is NULL, then the signal mask is unchanged (i.e., | |
93 | .I how | |
94 | is ignored), | |
95 | but the current value of the signal mask is nevertheless returned in | |
0daa9e92 | 96 | .I oldset |
53e67125 | 97 | (if it is not NULL). |
efeece04 | 98 | .PP |
35acdc5d MK |
99 | A set of functions for modifying and inspecting variables of type |
100 | .I sigset_t | |
101 | ("signal sets") is described in | |
102 | .BR sigsetops (3). | |
efeece04 | 103 | .PP |
7ff599e2 MK |
104 | The use of |
105 | .BR sigprocmask () | |
106 | is unspecified in a multithreaded process; see | |
107 | .BR pthread_sigmask (3). | |
47297adb | 108 | .SH RETURN VALUE |
7ff599e2 MK |
109 | .BR sigprocmask () |
110 | returns 0 on success and \-1 on error. | |
2cbd0ac5 MK |
111 | In the event of an error, |
112 | .I errno | |
113 | is set to indicate the cause. | |
7ff599e2 | 114 | .SH ERRORS |
ef301293 MF |
115 | .TP |
116 | .B EFAULT | |
57713dca | 117 | The |
ef301293 MF |
118 | .I set |
119 | or | |
120 | .I oldset | |
121 | argument points outside the process's allocated address space. | |
122 | .TP | |
7ff599e2 | 123 | .B EINVAL |
86d5ed87 | 124 | Either the value specified in |
7ff599e2 | 125 | .I how |
86d5ed87 KF |
126 | was invalid or the kernel does not support the size passed in |
127 | .I sigsetsize. | |
47297adb | 128 | .SH CONFORMING TO |
2b724927 | 129 | POSIX.1-2001, POSIX.1-2008. |
7ff599e2 | 130 | .SH NOTES |
c13182ef | 131 | It is not possible to block |
7ff599e2 MK |
132 | .BR SIGKILL " or " SIGSTOP . |
133 | Attempts to do so are silently ignored. | |
efeece04 | 134 | .PP |
92ae3965 | 135 | Each of the threads in a process has its own signal mask. |
efeece04 | 136 | .PP |
eebf482d MK |
137 | A child created via |
138 | .BR fork (2) | |
139 | inherits a copy of its parent's signal mask; | |
140 | the signal mask is preserved across | |
141 | .BR execve (2). | |
efeece04 | 142 | .PP |
7ff599e2 MK |
143 | If |
144 | .BR SIGBUS , | |
c13182ef | 145 | .BR SIGFPE , |
7ff599e2 MK |
146 | .BR SIGILL , |
147 | or | |
0daa9e92 | 148 | .B SIGSEGV |
7ff599e2 MK |
149 | are generated |
150 | while they are blocked, the result is undefined, | |
736bedf6 | 151 | unless the signal was generated by |
7ff599e2 | 152 | .BR kill (2), |
485ab701 | 153 | .BR sigqueue (3), |
7ff599e2 MK |
154 | or |
155 | .BR raise (3). | |
156 | .PP | |
157 | See | |
158 | .BR sigsetops (3) | |
159 | for details on manipulating signal sets. | |
efeece04 | 160 | .PP |
b9ad845d MK |
161 | Note that it is permissible (although not very useful) to specify both |
162 | .I set | |
163 | and | |
164 | .I oldset | |
165 | as NULL. | |
166b65db | 166 | .\" |
0722a578 | 167 | .SS C library/kernel differences |
efeece04 | 168 | .PP |
86d5ed87 KF |
169 | The kernel's definition of |
170 | .IR sigset_t | |
171 | differs in size from that used | |
6c79a020 MK |
172 | by the C library. |
173 | In this manual page, the former is referred to as | |
86d5ed87 | 174 | .I kernel_sigset_t |
6c79a020 | 175 | (it is nevertheless named |
86d5ed87 KF |
176 | .I sigset_t |
177 | in the kernel sources). | |
efeece04 | 178 | .PP |
3699b154 MK |
179 | The glibc wrapper function for |
180 | .BR sigprocmask () | |
181 | silently ignores attempts to block the two real-time signals that | |
182 | are used internally by the NPTL threading implementation. | |
183 | See | |
184 | .BR nptl (7) | |
185 | for details. | |
efeece04 | 186 | .PP |
166b65db MK |
187 | The original Linux system call was named |
188 | .BR sigprocmask (). | |
189 | However, with the addition of real-time signals in Linux 2.2, | |
190 | the fixed-size, 32-bit | |
191 | .IR sigset_t | |
86d5ed87 KF |
192 | (referred to as |
193 | .IR old_kernel_sigset_t | |
6c79a020 | 194 | in this manual page) |
166b65db MK |
195 | type supported by that system call was no longer fit for purpose. |
196 | Consequently, a new system call, | |
197 | .BR rt_sigprocmask (), | |
198 | was added to support an enlarged | |
199 | .IR sigset_t | |
86d5ed87 KF |
200 | type |
201 | (referred to as | |
202 | .IR kernel_sigset_t | |
6c79a020 | 203 | in this manual page). |
166b65db MK |
204 | The new system call takes a fourth argument, |
205 | .IR "size_t sigsetsize" , | |
206 | which specifies the size in bytes of the signal sets in | |
207 | .IR set | |
208 | and | |
209 | .IR oldset . | |
ad8c02ab DL |
210 | This argument is currently required to have a fixed architecture specific value |
211 | (equal to | |
212 | .IR sizeof(kernel_sigset_t) ). | |
213 | .\" sizeof(kernel_sigset_t) == _NSIG / 8, | |
214 | .\" which equals to 8 on most architectures, but e.g. on MIPS it's 16. | |
efeece04 | 215 | .PP |
166b65db MK |
216 | The glibc |
217 | .BR sigprocmask () | |
218 | wrapper function hides these details from us, transparently calling | |
219 | .BR rt_sigprocmask () | |
220 | when the kernel provides it. | |
221 | .\" | |
47297adb | 222 | .SH SEE ALSO |
7ff599e2 MK |
223 | .BR kill (2), |
224 | .BR pause (2), | |
225 | .BR sigaction (2), | |
226 | .BR signal (2), | |
227 | .BR sigpending (2), | |
7ff599e2 MK |
228 | .BR sigsuspend (2), |
229 | .BR pthread_sigmask (3), | |
485ab701 | 230 | .BR sigqueue (3), |
7ff599e2 MK |
231 | .BR sigsetops (3), |
232 | .BR signal (7) |