]>
Commit | Line | Data |
---|---|---|
9c2866d7 | 1 | '\" t |
c11b1abf | 2 | .\" Copyright (c) 2005 by Michael Kerrisk <mtk.manpages@gmail.com> |
9c2866d7 | 3 | .\" |
4b72fb64 | 4 | .\" %%%LICENSE_START(verbatim) |
9c2866d7 MK |
5 | .\" Permission is granted to make and distribute verbatim copies of this |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
13 | .\" | |
14 | .\" Since the Linux kernel and libraries are constantly changing, this | |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
10d76543 MK |
17 | .\" the use of the information contained herein. The author(s) may not |
18 | .\" have taken the same level of care in the production of this manual, | |
19 | .\" which is licensed free of charge, as they might when working | |
20 | .\" professionally. | |
9c2866d7 MK |
21 | .\" |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
9c2866d7 | 25 | .\" |
e191c685 | 26 | .TH SIGVEC 3 2012-09-06 "Linux" "Linux Programmer's Manual" |
9c2866d7 MK |
27 | .SH NAME |
28 | sigvec, sigblock, sigsetmask, siggetmask, sigmask \- BSD signal API | |
29 | .SH SYNOPSIS | |
9c2866d7 MK |
30 | .B #include <signal.h> |
31 | .sp | |
32 | .BI "int sigvec(int " sig ", struct sigvec *" vec ", struct sigvec *" ovec ); | |
33 | .sp | |
34 | .BI "int sigmask(int " signum ); | |
35 | .sp | |
36 | .BI "int sigblock(int " mask ); | |
37 | .sp | |
38 | .BI "int sigsetmask(int " mask ); | |
39 | .sp | |
40 | .B int siggetmask(void); | |
cc4615cc MK |
41 | .sp |
42 | .in -4n | |
43 | Feature Test Macro Requirements for glibc (see | |
44 | .BR feature_test_macros (7)): | |
45 | .in | |
46 | .sp | |
cfc2d88d | 47 | All functions shown above: |
cc4615cc | 48 | _BSD_SOURCE |
9c2866d7 MK |
49 | .SH DESCRIPTION |
50 | These functions are provided in glibc as a compatibility interface | |
51 | for programs that make use of the historical BSD signal API. | |
c13182ef MK |
52 | This API is obsolete: new applications should use the POSIX signal API |
53 | .RB ( sigaction (2), | |
9c2866d7 | 54 | .BR sigprocmask (2), |
1bea464c | 55 | etc.). |
9c2866d7 MK |
56 | |
57 | The | |
58 | .BR sigvec () | |
59 | function sets and/or gets the disposition of the signal | |
c13182ef | 60 | .I sig |
9c2866d7 MK |
61 | (like the POSIX |
62 | .BR sigaction (2)). | |
c13182ef | 63 | If |
9c2866d7 MK |
64 | .I vec |
65 | is not NULL, it points to a | |
66 | .I sigvec | |
c13182ef | 67 | structure that defines the new disposition for |
9c2866d7 MK |
68 | .IR sig . |
69 | If | |
70 | .I ovec | |
c13182ef | 71 | is not NULL, it points to a |
9c2866d7 MK |
72 | .I sigvec |
73 | structure that is used to return the previous disposition of | |
74 | .IR sig . | |
c13182ef | 75 | To obtain the current disposition of |
9c2866d7 MK |
76 | .I sig |
77 | without changing it, specify NULL for | |
c13182ef | 78 | .IR vec , |
9c2866d7 MK |
79 | and a non-NULL pointer for |
80 | .IR ovec . | |
81 | ||
82 | The dispositions for | |
83 | .B SIGKILL | |
c13182ef | 84 | and |
9c2866d7 MK |
85 | .B SIGSTOP |
86 | cannot be changed. | |
87 | ||
88 | The | |
89 | .I sigvec | |
90 | structure has the following form: | |
088a639b | 91 | .in +4n |
9c2866d7 MK |
92 | .nf |
93 | ||
94 | struct sigvec { | |
559a2b66 MK |
95 | void (*sv_handler)(int); /* Signal disposition */ |
96 | int sv_mask; /* Signals to be blocked in handler */ | |
97 | int sv_flags; /* Flags */ | |
9c2866d7 MK |
98 | }; |
99 | ||
100 | .fi | |
d4f3dcff | 101 | .in |
9c2866d7 MK |
102 | The |
103 | .I sv_handler | |
104 | field specifies the disposition of the signal, and is either: | |
4eaa04c5 | 105 | the address of a signal handler function; |
1bea464c | 106 | .BR SIG_DFL , |
9c2866d7 | 107 | meaning the default disposition applies for the signal; or |
1bea464c | 108 | .BR SIG_IGN , |
9c2866d7 MK |
109 | meaning that the signal is ignored. |
110 | ||
111 | If | |
112 | .I sv_handler | |
113 | specifies the address of a signal handler, then | |
114 | .I sv_mask | |
c13182ef | 115 | specifies a mask of signals that are to be blocked while |
9c2866d7 | 116 | the handler is executing. |
c13182ef | 117 | In addition, the signal for which the handler is invoked is |
e191c685 | 118 | also blocked. |
9c2866d7 MK |
119 | Attempts to block |
120 | .B SIGKILL | |
c13182ef | 121 | or |
9c2866d7 MK |
122 | .B SIGSTOP |
123 | are silently ignored. | |
124 | ||
125 | If | |
126 | .I sv_handler | |
127 | specifies the address of a signal handler, then the | |
128 | .I sv_flags | |
129 | field specifies flags controlling what happens when the handler is called. | |
130 | This field may contain zero or more of the following flags: | |
131 | .TP | |
132 | .B SV_INTERRUPT | |
133 | If the signal handler interrupts a blocking system call, | |
134 | then upon return from the handler the system call will not be restarted: | |
135 | instead it will fail with the error | |
7b2b5ea4 | 136 | .BR EINTR . |
c13182ef | 137 | If this flag is not specified, then system calls are restarted |
9c2866d7 MK |
138 | by default. |
139 | .TP | |
140 | .B SV_RESETHAND | |
c13182ef | 141 | Reset the disposition of the signal to the default |
9c2866d7 MK |
142 | before calling the signal handler. |
143 | If this flag is not specified, then the handler remains established | |
c13182ef | 144 | until explicitly removed by a later call to |
9c2866d7 MK |
145 | .BR sigvec () |
146 | or until the process performs an | |
147 | .BR execve (2). | |
148 | .TP | |
149 | .B SV_ONSTACK | |
c13182ef MK |
150 | Handle the signal on the alternate signal stack |
151 | (historically established under BSD using the obsolete | |
9c2866d7 | 152 | .BR sigstack () |
c13182ef | 153 | function; the POSIX replacement is |
fb186734 | 154 | .BR sigaltstack (2)). |
9c2866d7 | 155 | .PP |
c13182ef | 156 | The |
9c2866d7 MK |
157 | .BR sigmask () |
158 | function constructs and returns a "signal mask" for | |
159 | .IR signum . | |
d9bfdb9c | 160 | For example, we can initialize the |
c13182ef MK |
161 | .I vec.sv_mask |
162 | field given to | |
9c2866d7 MK |
163 | .BR sigvec () |
164 | using code such as the following: | |
165 | .nf | |
166 | ||
cf0a9ace | 167 | vec.sv_mask = sigmask(SIGQUIT) | sigpause(SIGABRT); |
c13182ef | 168 | /* Block SIGQUIT and SIGABRT during |
9c2866d7 MK |
169 | handler execution */ |
170 | .fi | |
171 | .PP | |
172 | The | |
173 | .BR sigblock () | |
174 | function adds the signals in | |
175 | .I mask | |
176 | to the process's signal mask | |
c13182ef | 177 | (like POSIX |
9c2866d7 MK |
178 | .IR sigprocmask(SIG_BLOCK) ), |
179 | and returns the process's previous signal mask. | |
180 | Attempts to block | |
181 | .B SIGKILL | |
c13182ef | 182 | or |
9c2866d7 MK |
183 | .B SIGSTOP |
184 | are silently ignored. | |
185 | .PP | |
c13182ef | 186 | The |
9c2866d7 MK |
187 | .BR sigsetmask () |
188 | function sets the process's signal mask to the value given in | |
c13182ef MK |
189 | .I mask |
190 | (like POSIX | |
9c2866d7 MK |
191 | .IR sigprocmask(SIG_SETMASK) ), |
192 | and returns the process's previous signal mask. | |
193 | .PP | |
194 | The | |
195 | .BR siggetmask () | |
196 | function returns the process's current signal mask. | |
197 | This call is equivalent to | |
198 | .IR sigblock(0) . | |
199 | .SH RETURN VALUE | |
c13182ef | 200 | The |
9c2866d7 MK |
201 | .BR sigvec () |
202 | function returns 0 on success; on error, it returns \-1 and sets | |
c13182ef | 203 | .I errno |
9c2866d7 MK |
204 | to indicate the error. |
205 | ||
206 | The | |
207 | .BR sigblock () | |
208 | and | |
209 | .BR sigsetmask () | |
210 | functions return the previous signal mask. | |
211 | ||
212 | The | |
213 | .BR sigmask () | |
214 | function returns the signal mask for | |
215 | .IR signum . | |
216 | .SH ERRORS | |
217 | See the ERRORS under | |
218 | .BR sigaction (2) | |
219 | and | |
220 | .BR sigprocmask (2). | |
47297adb | 221 | .SH CONFORMING TO |
2b2581ee MK |
222 | All of these functions were in |
223 | 4.3BSD, except | |
224 | .BR siggetmask (), | |
225 | whose origin is unclear. | |
226 | These functions are obsolete: do not use them in new programs. | |
9c2866d7 MK |
227 | .SH NOTES |
228 | On 4.3BSD, the | |
229 | .BR signal () | |
c13182ef | 230 | function provided reliable semantics (as when calling |
9c2866d7 MK |
231 | .BR sigvec () |
232 | with | |
233 | .I vec.sv_mask | |
234 | equal to 0). | |
235 | On System V, | |
236 | .BR signal () | |
237 | provides unreliable semantics. | |
c13182ef | 238 | POSIX.1-2001 leaves these aspects of |
9c2866d7 MK |
239 | .BR signal () |
240 | unspecified. | |
c13182ef | 241 | See |
9c2866d7 MK |
242 | .BR signal (2) |
243 | for further details. | |
244 | ||
245 | In order to wait for a signal, | |
246 | BSD and System V both provided a function named | |
7a056410 | 247 | .BR sigpause (3), |
9c2866d7 MK |
248 | but this function has a different argument on the two systems. |
249 | See | |
250 | .BR sigpause (3) | |
251 | for details. | |
47297adb | 252 | .SH SEE ALSO |
9c2866d7 MK |
253 | .BR kill (2), |
254 | .BR pause (2), | |
9c2866d7 MK |
255 | .BR sigaction (2), |
256 | .BR signal (2), | |
257 | .BR sigprocmask (2), | |
9fe51d8d | 258 | .BR raise (3), |
46c721e7 MK |
259 | .BR sigpause (3), |
260 | .BR sigset (3), | |
9c2866d7 | 261 | .BR signal (7) |