4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
43 #include <sys/feature_tests.h>
44 #include <sys/iso/signal_iso.h>
50 #if defined(__EXTENSIONS__) || defined(_KERNEL) || !defined(_STRICT_STDC) || \
51 defined(__XOPEN_OR_POSIX)
53 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
54 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
55 (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
57 * We need <sys/siginfo.h> for the declaration of siginfo_t.
59 #include <sys/siginfo.h>
62 /* Duplicated in <sys/ucontext.h> as a result of XPG4v2 requirements */
65 typedef struct { /* signal set type */
66 unsigned int __sigbits
[4];
68 #endif /* _SIGSET_T */
71 unsigned int __sigbits
[3];
75 * The signal handler routine can have either one or three arguments.
76 * Existing C code has used either form so not specifing the arguments
77 * neatly finesses the problem. C++ doesn't accept this. To C++
78 * "(*sa_handler)()" indicates a routine with no arguments (ANSI C would
79 * specify this as "(*sa_handler)(void)"). One or the other form must be
80 * used for C++ and the only logical choice is "(*sa_handler)(int)" to allow
81 * the SIG_* defines to work. "(*sa_sigaction)(int, siginfo_t *, void *)"
82 * can be used for the three argument form.
86 * Note: storage overlap by sa_handler and sa_sigaction
92 void (*_handler
)(int);
96 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
97 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
98 (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
99 void (*_sigaction
)(int, siginfo_t
*, void *);
107 #define sa_handler _funcptr._handler
108 #define sa_sigaction _funcptr._sigaction
110 #if defined(_SYSCALL32)
112 /* Kernel view of the ILP32 user sigaction structure */
118 caddr32_t _sigaction
;
124 #endif /* _SYSCALL32 */
126 /* this is only valid for SIGCLD */
127 #define SA_NOCLDSTOP 0x00020000 /* don't send job control SIGCLD's */
130 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
131 (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
134 /* non-conformant ANSI compilation */
136 /* definitions for the sa_flags field */
137 #define SA_ONSTACK 0x00000001
138 #define SA_RESETHAND 0x00000002
139 #define SA_RESTART 0x00000004
142 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
143 (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
144 (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
145 #define SA_SIGINFO 0x00000008
148 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
149 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
151 #define SA_NODEFER 0x00000010
153 /* this is only valid for SIGCLD */
154 #define SA_NOCLDWAIT 0x00010000 /* don't save zombie children */
156 #if defined(__EXTENSIONS__) || !defined(_XPG4_2)
158 * use of these symbols by applications is injurious
159 * to binary compatibility
161 #define NSIG 74 /* valid signals range from 1 to NSIG-1 */
162 #define MAXSIG 73 /* size of u_signal[], NSIG-1 <= MAXSIG */
163 #endif /* defined(__EXTENSIONS__) || !defined(_XPG4_2) */
165 #define MINSIGSTKSZ 2048
166 #define SIGSTKSZ 8192
168 #define SS_ONSTACK 0x00000001
169 #define SS_DISABLE 0x00000002
171 /* Duplicated in <sys/ucontext.h> as a result of XPG4v2 requirements. */
174 #if defined(__EXTENSIONS__) || !defined(_XPG4_2)
175 typedef struct sigaltstack
{
184 #if defined(_SYSCALL32)
186 /* Kernel view of the ILP32 user sigaltstack structure */
188 typedef struct sigaltstack32
{
194 #endif /* _SYSCALL32 */
196 #endif /* _STACK_T */
198 #endif /* defined(__EXTENSIONS__) || defined(_KERNEL) ... */
200 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
201 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
203 /* signotify id used only by libc for mq_notify()/aio_notify() */
204 typedef struct signotify_id
{ /* signotify id struct */
205 pid_t sn_pid
; /* pid of proc to be notified */
206 int sn_index
; /* index in preallocated pool */
207 int sn_pad
; /* reserved */
210 #if defined(_SYSCALL32)
212 /* Kernel view of the ILP32 user signotify_id structure */
214 typedef struct signotify32_id
{
215 pid32_t sn_pid
; /* pid of proc to be notified */
216 int32_t sn_index
; /* index in preallocated pool */
217 int32_t sn_pad
; /* reserved */
220 #endif /* _SYSCALL32 */
222 /* Command codes for sig_notify call */
224 #define SN_PROC 1 /* queue signotify for process */
225 #define SN_CANCEL 2 /* cancel the queued signotify */
226 #define SN_SEND 3 /* send the notified signal */
228 #endif /* defined(__EXTENSIONS__) || defined(_KERNEL) ... */
230 /* Added as per XPG4v2 */
231 #if defined(__EXTENSIONS__) || defined(_KERNEL) || \
232 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
238 #endif /* defined(__EXTENSIONS__) || defined(_KERNEL) ... */
241 * For definition of ucontext_t; must follow struct definition
245 #include <sys/ucontext.h>
246 #endif /* defined(_XPG4_2) */
249 #include <sys/t_lock.h>
251 extern const k_sigset_t nullsmask
; /* a null signal mask */
252 extern const k_sigset_t fillset
; /* all signals, guaranteed contiguous */
253 extern const k_sigset_t cantmask
; /* cannot be caught or ignored */
254 extern const k_sigset_t cantreset
; /* cannot be reset after catching */
255 extern const k_sigset_t ignoredefault
; /* ignored by default */
256 extern const k_sigset_t stopdefault
; /* stop by default */
257 extern const k_sigset_t coredefault
; /* dumps core by default */
258 extern const k_sigset_t holdvfork
; /* held while doing vfork */
260 #define sigmask(n) ((unsigned int)1 << (((n) - 1) & (32 - 1)))
261 #define sigword(n) (((unsigned int)((n) - 1))>>5)
263 #if ((MAXSIG > (2 * 32)) && (MAXSIG <= (3 * 32)))
264 #define FILLSET0 0xffffffffu
265 #define FILLSET1 0xffffffffu
266 #define FILLSET2 ((1u << (MAXSIG - 64)) - 1)
268 #error "fix me: MAXSIG out of bounds"
271 #define CANTMASK0 (sigmask(SIGKILL)|sigmask(SIGSTOP))
275 #define sigemptyset(s) (*(s) = nullsmask)
276 #define sigfillset(s) (*(s) = fillset)
277 #define sigaddset(s, n) ((s)->__sigbits[sigword(n)] |= sigmask(n))
278 #define sigdelset(s, n) ((s)->__sigbits[sigword(n)] &= ~sigmask(n))
279 #define sigismember(s, n) (sigmask(n) & (s)->__sigbits[sigword(n)])
280 #define sigisempty(s) (!((s)->__sigbits[0] | (s)->__sigbits[1] | \
282 #define sigutok(us, ks) \
283 ((ks)->__sigbits[0] = (us)->__sigbits[0] & (FILLSET0 & ~CANTMASK0), \
284 (ks)->__sigbits[1] = (us)->__sigbits[1] & (FILLSET1 & ~CANTMASK1), \
285 (ks)->__sigbits[2] = (us)->__sigbits[2] & (FILLSET2 & ~CANTMASK2))
286 #define sigktou(ks, us) ((us)->__sigbits[0] = (ks)->__sigbits[0], \
287 (us)->__sigbits[1] = (ks)->__sigbits[1], \
288 (us)->__sigbits[2] = (ks)->__sigbits[2], \
289 (us)->__sigbits[3] = 0)
291 int sig
; /* signal no. */
292 int perm
; /* flag for EPERM */
293 int checkperm
; /* check perm or not */
294 int sicode
; /* has siginfo.si_code */
295 union sigval value
; /* user specified value */
299 sigqueue_t sn_sigq
; /* sigq struct for notification */
300 u_longlong_t sn_snid
; /* unique id for notification */
303 typedef struct sigqhdr
{ /* sigqueue pool header */
304 sigqueue_t
*sqb_free
; /* free sigq struct list */
305 int sqb_count
; /* sigq free count */
306 uint_t sqb_maxcount
; /* sigq max free count */
307 size_t sqb_size
; /* size of header+free structs */
308 uchar_t sqb_pexited
; /* process has exited */
309 uint_t sqb_sent
; /* number of sigq sent */
310 kcondvar_t sqb_cv
; /* waiting for a sigq struct */
311 kmutex_t sqb_lock
; /* lock for sigq pool */
314 #define _SIGQUEUE_SIZE_BASIC 128 /* basic limit */
315 #define _SIGQUEUE_SIZE_PRIVILEGED 512 /* privileged limit */
317 #define _SIGNOTIFY_MAX 32
319 extern void setsigact(int, void (*)(int), const k_sigset_t
*, int);
320 extern void sigorset(k_sigset_t
*, const k_sigset_t
*);
321 extern void sigandset(k_sigset_t
*, const k_sigset_t
*);
322 extern void sigdiffset(k_sigset_t
*, const k_sigset_t
*);
323 extern void sigintr(k_sigset_t
*, int);
324 extern void sigunintr(k_sigset_t
*);
325 extern void sigreplace(k_sigset_t
*, k_sigset_t
*);
327 extern int kill(pid_t
, int);
335 #endif /* _SYS_SIGNAL_H */