Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/signal.h
+++ new/usr/src/uts/common/sys/signal.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 * Copyright 2015, Joyent, Inc.
26 26 */
27 27
28 28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
29 29 /* All Rights Reserved */
30 30
31 31 /*
32 32 * University Copyright- Copyright (c) 1982, 1986, 1988
33 33 * The Regents of the University of California
34 34 * All Rights Reserved
35 35 *
36 36 * University Acknowledgment- Portions of this document are derived from
37 37 * software developed by the University of California, Berkeley, and its
38 38 * contributors.
39 39 */
40 40
41 41 #ifndef _SYS_SIGNAL_H
42 42 #define _SYS_SIGNAL_H
43 43
44 44 #include <sys/feature_tests.h>
45 45 #include <sys/iso/signal_iso.h>
46 46
47 47 #ifdef __cplusplus
48 48 extern "C" {
49 49 #endif
50 50
51 51 #if defined(__EXTENSIONS__) || defined(_KERNEL) || !defined(_STRICT_STDC) || \
52 52 defined(__XOPEN_OR_POSIX)
53 53
54 54 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
55 55 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
56 56 (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
57 57 /*
58 58 * We need <sys/siginfo.h> for the declaration of siginfo_t.
59 59 */
60 60 #include <sys/siginfo.h>
61 61 #endif
62 62
63 63 /* Duplicated in <sys/ucontext.h> as a result of XPG4v2 requirements */
64 64 #ifndef _SIGSET_T
65 65 #define _SIGSET_T
66 66 typedef struct { /* signal set type */
67 67 unsigned int __sigbits[4];
68 68 } sigset_t;
69 69 #endif /* _SIGSET_T */
70 70
71 71 typedef struct {
72 72 unsigned int __sigbits[3];
73 73 } k_sigset_t;
74 74
75 75 /*
76 76 * The signal handler routine can have either one or three arguments.
77 77 * Existing C code has used either form so not specifing the arguments
78 78 * neatly finesses the problem. C++ doesn't accept this. To C++
79 79 * "(*sa_handler)()" indicates a routine with no arguments (ANSI C would
80 80 * specify this as "(*sa_handler)(void)"). One or the other form must be
81 81 * used for C++ and the only logical choice is "(*sa_handler)(int)" to allow
82 82 * the SIG_* defines to work. "(*sa_sigaction)(int, siginfo_t *, void *)"
83 83 * can be used for the three argument form.
84 84 */
85 85
86 86 /*
87 87 * Note: storage overlap by sa_handler and sa_sigaction
88 88 */
89 89 struct sigaction {
90 90 int sa_flags;
91 91 union {
92 92 #ifdef __cplusplus
93 93 void (*_handler)(int);
94 94 #else
95 95 void (*_handler)();
96 96 #endif
97 97 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
98 98 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
99 99 (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
100 100 void (*_sigaction)(int, siginfo_t *, void *);
101 101 #endif
102 102 } _funcptr;
103 103 sigset_t sa_mask;
104 104 #ifndef _LP64
105 105 int sa_resv[2];
106 106 #endif
107 107 };
108 108 #define sa_handler _funcptr._handler
109 109 #define sa_sigaction _funcptr._sigaction
110 110
111 111 #if defined(_SYSCALL32)
112 112
113 113 /* Kernel view of the ILP32 user sigaction structure */
114 114
115 115 struct sigaction32 {
116 116 int32_t sa_flags;
117 117 union {
118 118 caddr32_t _handler;
119 119 caddr32_t _sigaction;
120 120 } _funcptr;
121 121 sigset_t sa_mask;
122 122 int32_t sa_resv[2];
123 123 };
124 124
125 125 #endif /* _SYSCALL32 */
126 126
127 127 /* this is only valid for SIGCLD */
128 128 #define SA_NOCLDSTOP 0x00020000 /* don't send job control SIGCLD's */
129 129 #endif
130 130
131 131 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
132 132 (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
133 133 defined(_XPG4_2)
134 134
135 135 /* non-conformant ANSI compilation */
136 136
137 137 /* definitions for the sa_flags field */
138 138 #define SA_ONSTACK 0x00000001
139 139 #define SA_RESETHAND 0x00000002
140 140 #define SA_RESTART 0x00000004
141 141 #endif
142 142
143 143 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
144 144 (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
145 145 (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
146 146 #define SA_SIGINFO 0x00000008
147 147 #endif
148 148
149 149 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
150 150 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
151 151 defined(_XPG4_2)
152 152 #define SA_NODEFER 0x00000010
153 153
154 154 /* this is only valid for SIGCLD */
155 155 #define SA_NOCLDWAIT 0x00010000 /* don't save zombie children */
156 156
157 157 #if defined(__EXTENSIONS__) || !defined(_XPG4_2)
158 158 /*
159 159 * use of these symbols by applications is injurious
160 160 * to binary compatibility
161 161 */
162 162 #define NSIG 75 /* valid signals range from 1 to NSIG-1 */
163 163 #define MAXSIG 74 /* size of u_signal[], NSIG-1 <= MAXSIG */
164 164 #endif /* defined(__EXTENSIONS__) || !defined(_XPG4_2) */
165 165
166 166 #define MINSIGSTKSZ 2048
167 167 #define SIGSTKSZ 8192
168 168
169 169 #define SS_ONSTACK 0x00000001
170 170 #define SS_DISABLE 0x00000002
171 171
172 172 /* Duplicated in <sys/ucontext.h> as a result of XPG4v2 requirements. */
173 173 #ifndef _STACK_T
174 174 #define _STACK_T
175 175 #if defined(__EXTENSIONS__) || !defined(_XPG4_2)
176 176 typedef struct sigaltstack {
177 177 #else
178 178 typedef struct {
179 179 #endif
180 180 void *ss_sp;
181 181 size_t ss_size;
182 182 int ss_flags;
183 183 } stack_t;
184 184
185 185 #if defined(_SYSCALL32)
186 186
187 187 /* Kernel view of the ILP32 user sigaltstack structure */
188 188
189 189 typedef struct sigaltstack32 {
190 190 caddr32_t ss_sp;
191 191 size32_t ss_size;
192 192 int32_t ss_flags;
193 193 } stack32_t;
194 194
195 195 #endif /* _SYSCALL32 */
196 196
197 197 #endif /* _STACK_T */
198 198
199 199 #endif /* defined(__EXTENSIONS__) || defined(_KERNEL) ... */
200 200
201 201 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
202 202 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
203 203
204 204 /* signotify id used only by libc for mq_notify()/aio_notify() */
205 205 typedef struct signotify_id { /* signotify id struct */
206 206 pid_t sn_pid; /* pid of proc to be notified */
207 207 int sn_index; /* index in preallocated pool */
208 208 int sn_pad; /* reserved */
209 209 } signotify_id_t;
210 210
211 211 #if defined(_SYSCALL32)
212 212
213 213 /* Kernel view of the ILP32 user signotify_id structure */
214 214
215 215 typedef struct signotify32_id {
216 216 pid32_t sn_pid; /* pid of proc to be notified */
217 217 int32_t sn_index; /* index in preallocated pool */
218 218 int32_t sn_pad; /* reserved */
219 219 } signotify32_id_t;
220 220
221 221 #endif /* _SYSCALL32 */
222 222
223 223 /* Command codes for sig_notify call */
224 224
225 225 #define SN_PROC 1 /* queue signotify for process */
226 226 #define SN_CANCEL 2 /* cancel the queued signotify */
227 227 #define SN_SEND 3 /* send the notified signal */
228 228
229 229 #endif /* defined(__EXTENSIONS__) || defined(_KERNEL) ... */
230 230
231 231 /* Added as per XPG4v2 */
232 232 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
233 233 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
234 234 defined(_XPG4_2)
235 235 struct sigstack {
236 236 void *ss_sp;
237 237 int ss_onstack;
238 238 };
239 239 #endif /* defined(__EXTENSIONS__) || defined(_KERNEL) ... */
240 240
241 241 /*
242 242 * For definition of ucontext_t; must follow struct definition
243 243 * for sigset_t
244 244 */
245 245 #if defined(_XPG4_2)
246 246 #include <sys/ucontext.h>
247 247 #endif /* defined(_XPG4_2) */
248 248
249 249 #ifdef _KERNEL
250 250 #include <sys/t_lock.h>
251 251
252 252 extern const k_sigset_t nullsmask; /* a null signal mask */
253 253 extern const k_sigset_t fillset; /* all signals, guaranteed contiguous */
254 254 extern const k_sigset_t cantmask; /* cannot be caught or ignored */
255 255 extern const k_sigset_t cantreset; /* cannot be reset after catching */
256 256 extern const k_sigset_t ignoredefault; /* ignored by default */
257 257 extern const k_sigset_t stopdefault; /* stop by default */
258 258 extern const k_sigset_t coredefault; /* dumps core by default */
259 259 extern const k_sigset_t holdvfork; /* held while doing vfork */
260 260
261 261 #define sigmask(n) ((unsigned int)1 << (((n) - 1) & (32 - 1)))
262 262 #define sigword(n) (((unsigned int)((n) - 1))>>5)
263 263
264 264 #if ((MAXSIG > (2 * 32)) && (MAXSIG <= (3 * 32)))
265 265 #define FILLSET0 0xffffffffu
266 266 #define FILLSET1 0xffffffffu
267 267 #define FILLSET2 ((1u << (MAXSIG - 64)) - 1)
268 268 #else
269 269 #error "fix me: MAXSIG out of bounds"
270 270 #endif
271 271
272 272 #define CANTMASK0 (sigmask(SIGKILL)|sigmask(SIGSTOP))
273 273 #define CANTMASK1 0
274 274 #define CANTMASK2 0
275 275
276 276 #define sigemptyset(s) (*(s) = nullsmask)
277 277 #define sigfillset(s) (*(s) = fillset)
278 278 #define sigaddset(s, n) ((s)->__sigbits[sigword(n)] |= sigmask(n))
279 279 #define sigdelset(s, n) ((s)->__sigbits[sigword(n)] &= ~sigmask(n))
280 280 #define sigismember(s, n) (sigmask(n) & (s)->__sigbits[sigword(n)])
281 281 #define sigisempty(s) (!((s)->__sigbits[0] | (s)->__sigbits[1] | \
282 282 (s)->__sigbits[2]))
283 283 #define sigutok(us, ks) \
284 284 ((ks)->__sigbits[0] = (us)->__sigbits[0] & (FILLSET0 & ~CANTMASK0), \
285 285 (ks)->__sigbits[1] = (us)->__sigbits[1] & (FILLSET1 & ~CANTMASK1), \
286 286 (ks)->__sigbits[2] = (us)->__sigbits[2] & (FILLSET2 & ~CANTMASK2))
287 287 #define sigktou(ks, us) ((us)->__sigbits[0] = (ks)->__sigbits[0], \
288 288 (us)->__sigbits[1] = (ks)->__sigbits[1], \
289 289 (us)->__sigbits[2] = (ks)->__sigbits[2], \
290 290 (us)->__sigbits[3] = 0)
291 291 typedef struct {
292 292 int sig; /* signal no. */
293 293 int perm; /* flag for EPERM */
294 294 int checkperm; /* check perm or not */
295 295 int sicode; /* has siginfo.si_code */
296 296 union sigval value; /* user specified value */
297 297 } sigsend_t;
298 298
299 299 typedef struct {
300 300 sigqueue_t sn_sigq; /* sigq struct for notification */
301 301 u_longlong_t sn_snid; /* unique id for notification */
302 302 } signotifyq_t;
303 303
304 304 typedef struct sigqhdr { /* sigqueue pool header */
305 305 sigqueue_t *sqb_free; /* free sigq struct list */
306 306 int sqb_count; /* sigq free count */
307 307 uint_t sqb_maxcount; /* sigq max free count */
308 308 size_t sqb_size; /* size of header+free structs */
309 309 uchar_t sqb_pexited; /* process has exited */
310 310 uint_t sqb_sent; /* number of sigq sent */
311 311 kcondvar_t sqb_cv; /* waiting for a sigq struct */
312 312 kmutex_t sqb_lock; /* lock for sigq pool */
313 313 } sigqhdr_t;
314 314
315 315 #define _SIGQUEUE_SIZE_BASIC 128 /* basic limit */
316 316 #define _SIGQUEUE_SIZE_PRIVILEGED 512 /* privileged limit */
317 317
318 318 #define _SIGNOTIFY_MAX 32
319 319
320 320 extern void setsigact(int, void (*)(int), const k_sigset_t *, int);
321 321 extern void sigorset(k_sigset_t *, const k_sigset_t *);
322 322 extern void sigandset(k_sigset_t *, const k_sigset_t *);
323 323 extern void sigdiffset(k_sigset_t *, const k_sigset_t *);
324 324 extern void sigintr(k_sigset_t *, int);
325 325 extern void sigunintr(k_sigset_t *);
326 326 extern void sigreplace(k_sigset_t *, k_sigset_t *);
327 327
328 328 extern int kill(pid_t, int);
329 329
330 330 #endif /* _KERNEL */
331 331
332 332 #ifdef __cplusplus
333 333 }
334 334 #endif
335 335
336 336 #endif /* _SYS_SIGNAL_H */
|
↓ open down ↓ |
336 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX