]>
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 | .\" | |
97986708 | 29 | .TH SIGPROCMASK 2 2016-03-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> | |
c13182ef | 34 | .sp |
7ff599e2 MK |
35 | .BI "int sigprocmask(int " how ", const sigset_t *" set , |
36 | .BI "sigset_t *" oldset ); | |
0f200f07 MK |
37 | .sp |
38 | .in -4n | |
39 | Feature Test Macro Requirements for glibc (see | |
40 | .BR feature_test_macros (7)): | |
41 | .in | |
42 | .sp | |
43 | .ad l | |
44 | .BR sigprocmask (): | |
cff459de | 45 | _POSIX_C_SOURCE |
0f200f07 | 46 | .ad b |
7ff599e2 MK |
47 | .SH DESCRIPTION |
48 | .BR sigprocmask () | |
92ae3965 MK |
49 | is used to fetch and/or change the signal mask of the calling thread. |
50 | The signal mask is the set of signals whose delivery is currently | |
51 | blocked for the caller | |
4c5bcd47 MK |
52 | (see also |
53 | .BR signal (7) | |
54 | for more details). | |
55 | ||
d9bfdb9c | 56 | The behavior of the call is dependent on the value of |
7ff599e2 MK |
57 | .IR how , |
58 | as follows. | |
7ff599e2 MK |
59 | .TP |
60 | .B SIG_BLOCK | |
61 | The set of blocked signals is the union of the current set and the | |
62 | .I set | |
63 | argument. | |
64 | .TP | |
65 | .B SIG_UNBLOCK | |
66 | The signals in | |
67 | .I set | |
c13182ef | 68 | are removed from the current set of blocked signals. |
e935e108 | 69 | It is permissible to attempt to unblock a signal which is not blocked. |
7ff599e2 MK |
70 | .TP |
71 | .B SIG_SETMASK | |
72 | The set of blocked signals is set to the argument | |
73 | .IR set . | |
7ff599e2 MK |
74 | .PP |
75 | If | |
76 | .I oldset | |
f38d8f71 | 77 | is non-NULL, the previous value of the signal mask is stored in |
7ff599e2 MK |
78 | .IR oldset . |
79 | ||
80 | If | |
81 | .I set | |
82 | is NULL, then the signal mask is unchanged (i.e., | |
83 | .I how | |
84 | is ignored), | |
85 | but the current value of the signal mask is nevertheless returned in | |
0daa9e92 | 86 | .I oldset |
53e67125 | 87 | (if it is not NULL). |
7ff599e2 | 88 | |
35acdc5d MK |
89 | A set of functions for modifying and inspecting variables of type |
90 | .I sigset_t | |
91 | ("signal sets") is described in | |
92 | .BR sigsetops (3). | |
93 | ||
7ff599e2 MK |
94 | The use of |
95 | .BR sigprocmask () | |
96 | is unspecified in a multithreaded process; see | |
97 | .BR pthread_sigmask (3). | |
47297adb | 98 | .SH RETURN VALUE |
7ff599e2 MK |
99 | .BR sigprocmask () |
100 | returns 0 on success and \-1 on error. | |
2cbd0ac5 MK |
101 | In the event of an error, |
102 | .I errno | |
103 | is set to indicate the cause. | |
7ff599e2 | 104 | .SH ERRORS |
ef301293 MF |
105 | .TP |
106 | .B EFAULT | |
57713dca | 107 | The |
ef301293 MF |
108 | .I set |
109 | or | |
110 | .I oldset | |
111 | argument points outside the process's allocated address space. | |
112 | .TP | |
7ff599e2 MK |
113 | .B EINVAL |
114 | The value specified in | |
115 | .I how | |
116 | was invalid. | |
47297adb | 117 | .SH CONFORMING TO |
2b724927 | 118 | POSIX.1-2001, POSIX.1-2008. |
7ff599e2 | 119 | .SH NOTES |
c13182ef | 120 | It is not possible to block |
7ff599e2 MK |
121 | .BR SIGKILL " or " SIGSTOP . |
122 | Attempts to do so are silently ignored. | |
eebf482d | 123 | |
92ae3965 MK |
124 | Each of the threads in a process has its own signal mask. |
125 | ||
eebf482d MK |
126 | A child created via |
127 | .BR fork (2) | |
128 | inherits a copy of its parent's signal mask; | |
129 | the signal mask is preserved across | |
130 | .BR execve (2). | |
131 | ||
7ff599e2 MK |
132 | If |
133 | .BR SIGBUS , | |
c13182ef | 134 | .BR SIGFPE , |
7ff599e2 MK |
135 | .BR SIGILL , |
136 | or | |
0daa9e92 | 137 | .B SIGSEGV |
7ff599e2 MK |
138 | are generated |
139 | while they are blocked, the result is undefined, | |
736bedf6 | 140 | unless the signal was generated by |
7ff599e2 | 141 | .BR kill (2), |
485ab701 | 142 | .BR sigqueue (3), |
7ff599e2 MK |
143 | or |
144 | .BR raise (3). | |
145 | .PP | |
146 | See | |
147 | .BR sigsetops (3) | |
148 | for details on manipulating signal sets. | |
166b65db | 149 | .\" |
0722a578 | 150 | .SS C library/kernel differences |
3699b154 MK |
151 | The glibc wrapper function for |
152 | .BR sigprocmask () | |
153 | silently ignores attempts to block the two real-time signals that | |
154 | are used internally by the NPTL threading implementation. | |
155 | See | |
156 | .BR nptl (7) | |
157 | for details. | |
158 | ||
166b65db MK |
159 | The original Linux system call was named |
160 | .BR sigprocmask (). | |
161 | However, with the addition of real-time signals in Linux 2.2, | |
162 | the fixed-size, 32-bit | |
163 | .IR sigset_t | |
164 | type supported by that system call was no longer fit for purpose. | |
165 | Consequently, a new system call, | |
166 | .BR rt_sigprocmask (), | |
167 | was added to support an enlarged | |
168 | .IR sigset_t | |
169 | type. | |
170 | The new system call takes a fourth argument, | |
171 | .IR "size_t sigsetsize" , | |
172 | which specifies the size in bytes of the signal sets in | |
173 | .IR set | |
174 | and | |
175 | .IR oldset . | |
176 | This argument is currently required to have the value | |
177 | .IR sizeof(sigset_t) | |
178 | (or the error | |
179 | .B EINVAL | |
180 | results). | |
181 | The glibc | |
182 | .BR sigprocmask () | |
183 | wrapper function hides these details from us, transparently calling | |
184 | .BR rt_sigprocmask () | |
185 | when the kernel provides it. | |
186 | .\" | |
47297adb | 187 | .SH SEE ALSO |
7ff599e2 MK |
188 | .BR kill (2), |
189 | .BR pause (2), | |
190 | .BR sigaction (2), | |
191 | .BR signal (2), | |
192 | .BR sigpending (2), | |
7ff599e2 MK |
193 | .BR sigsuspend (2), |
194 | .BR pthread_sigmask (3), | |
485ab701 | 195 | .BR sigqueue (3), |
7ff599e2 MK |
196 | .BR sigsetops (3), |
197 | .BR signal (7) |