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