signalvar.h revision 42379
1/* 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)signalvar.h 8.6 (Berkeley) 2/19/95 34 * $Id: signalvar.h,v 1.21 1998/12/19 02:55:34 julian Exp $ 35 */ 36 37#ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */ 38#define _SYS_SIGNALVAR_H_ 39 40#include <sys/signal.h> 41 42/* 43 * Kernel signal definitions and data structures, 44 * not exported to user programs. 45 */ 46 47/* 48 * Process signal actions and state, needed only within the process 49 * (not necessarily resident). 50 */ 51struct sigacts { 52 sig_t ps_sigact[NSIG]; /* disposition of signals */ 53 sigset_t ps_catchmask[NSIG]; /* signals to be blocked */ 54 sigset_t ps_sigonstack; /* signals to take on sigstack */ 55 sigset_t ps_sigintr; /* signals that interrupt syscalls */ 56 sigset_t ps_sigreset; /* signals that reset when caught */ 57 sigset_t ps_signodefer; /* signals not masked while handled */ 58#ifndef COMPAT_LINUX_THREADS 59 sigset_t ps_oldmask; /* saved mask from before sigpause */ 60#endif /* COMPAT_LINUX_THREADS */ 61 int ps_flags; /* signal flags, below */ 62 struct sigaltstack ps_sigstk; /* sp & on stack state variable */ 63#ifndef COMPAT_LINUX_THREADS 64 int ps_sig; /* for core dump/debugger XXX */ 65 u_long ps_code; /* for core dump/debugger XXX */ 66#endif /* COMPAT_LINUX_THREADS */ 67 sigset_t ps_usertramp; /* SunOS compat; libc sigtramp XXX */ 68}; 69 70/* signal flags */ 71#define SAS_OLDMASK 0x01 /* need to restore mask before pause */ 72#define SAS_ALTSTACK 0x02 /* have alternate signal stack */ 73 74/* additional signal action values, used only temporarily/internally */ 75#define SIG_CATCH ((__sighandler_t *)2) 76#define SIG_HOLD ((__sighandler_t *)3) 77 78/* 79 * get signal action for process and signal; currently only for current process 80 */ 81#define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[(sig)]) 82 83/* 84 * Determine signal that should be delivered to process p, the current 85 * process, 0 if none. If there is a pending stop signal with default 86 * action, the process stops in issignal(). 87 */ 88#define CURSIG(p) \ 89 (((p)->p_siglist == 0 || \ 90 (((p)->p_flag & P_TRACED) == 0 && \ 91 ((p)->p_siglist & ~(p)->p_sigmask) == 0)) ? \ 92 0 : issignal(p)) 93 94/* 95 * Clear a pending signal from a process. 96 */ 97#define CLRSIG(p, sig) { (p)->p_siglist &= ~sigmask(sig); } 98 99/* 100 * Signal properties and actions. 101 * The array below categorizes the signals and their default actions 102 * according to the following properties: 103 */ 104#define SA_KILL 0x01 /* terminates process by default */ 105#define SA_CORE 0x02 /* ditto and coredumps */ 106#define SA_STOP 0x04 /* suspend process */ 107#define SA_TTYSTOP 0x08 /* ditto, from tty */ 108#define SA_IGNORE 0x10 /* ignore by default */ 109#define SA_CONT 0x20 /* continue if suspended */ 110#define SA_CANTMASK 0x40 /* non-maskable, catchable */ 111 112#ifdef SIGPROP 113static int sigprop[NSIG + 1] = { 114 0, /* unused */ 115 SA_KILL, /* SIGHUP */ 116 SA_KILL, /* SIGINT */ 117 SA_KILL|SA_CORE, /* SIGQUIT */ 118 SA_KILL|SA_CORE, /* SIGILL */ 119 SA_KILL|SA_CORE, /* SIGTRAP */ 120 SA_KILL|SA_CORE, /* SIGABRT */ 121 SA_KILL|SA_CORE, /* SIGEMT */ 122 SA_KILL|SA_CORE, /* SIGFPE */ 123 SA_KILL, /* SIGKILL */ 124 SA_KILL|SA_CORE, /* SIGBUS */ 125 SA_KILL|SA_CORE, /* SIGSEGV */ 126 SA_KILL|SA_CORE, /* SIGSYS */ 127 SA_KILL, /* SIGPIPE */ 128 SA_KILL, /* SIGALRM */ 129 SA_KILL, /* SIGTERM */ 130 SA_IGNORE, /* SIGURG */ 131 SA_STOP, /* SIGSTOP */ 132 SA_STOP|SA_TTYSTOP, /* SIGTSTP */ 133 SA_IGNORE|SA_CONT, /* SIGCONT */ 134 SA_IGNORE, /* SIGCHLD */ 135 SA_STOP|SA_TTYSTOP, /* SIGTTIN */ 136 SA_STOP|SA_TTYSTOP, /* SIGTTOU */ 137 SA_IGNORE, /* SIGIO */ 138 SA_KILL, /* SIGXCPU */ 139 SA_KILL, /* SIGXFSZ */ 140 SA_KILL, /* SIGVTALRM */ 141 SA_KILL, /* SIGPROF */ 142 SA_IGNORE, /* SIGWINCH */ 143 SA_IGNORE, /* SIGINFO */ 144 SA_KILL, /* SIGUSR1 */ 145 SA_KILL, /* SIGUSR2 */ 146}; 147 148#define contsigmask (sigmask(SIGCONT)) 149#define stopsigmask (sigmask(SIGSTOP) | sigmask(SIGTSTP) | \ 150 sigmask(SIGTTIN) | sigmask(SIGTTOU)) 151 152#endif /* SIGPROP */ 153 154#define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP)) 155 156#ifdef KERNEL 157struct pgrp; 158struct proc; 159struct sigio; 160 161extern int sugid_coredump; /* Sysctl variable kern.sugid_coredump */ 162 163/* 164 * Machine-independent functions: 165 */ 166void execsigs __P((struct proc *p)); 167char *expand_name __P((const char*, int, int)); 168void gsignal __P((int pgid, int sig)); 169int issignal __P((struct proc *p)); 170void killproc __P((struct proc *p, char *why)); 171void pgsigio __P((struct sigio *, int signum, int checkctty)); 172void pgsignal __P((struct pgrp *pgrp, int sig, int checkctty)); 173void postsig __P((int sig)); 174void psignal __P((struct proc *p, int sig)); 175void sigexit __P((struct proc *p, int signum)); 176void siginit __P((struct proc *p)); 177void trapsignal __P((struct proc *p, int sig, u_long code)); 178#ifdef COMPAT_LINUX_THREADS 179void check_sigacts (void); 180#endif 181/* 182 * Machine-dependent functions: 183 */ 184void sendsig __P((sig_t action, int sig, int returnmask, u_long code)); 185#endif /* KERNEL */ 186#endif /* !_SYS_SIGNALVAR_H_ */ 187