1 /* 2 * Copyright (c) 1991 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)signalvar.h 7.4 (Berkeley) 02/05/92 8 */ 9 10 #ifndef _SIGNALVAR_H_ /* tmp for user.h */ 11 #define _SIGNALVAR_H_ 12 13 /* 14 * Kernel signal definitions and data structures, 15 * not exported to user programs. 16 */ 17 18 /* 19 * Process signal actions and state, needed only within the process 20 * (not necessarily resident). 21 */ 22 struct sigacts { 23 sig_t ps_sigact[NSIG]; /* disposition of signals */ 24 sigset_t ps_catchmask[NSIG]; /* signals to be blocked */ 25 sigset_t ps_sigonstack; /* signals to take on sigstack */ 26 sigset_t ps_sigintr; /* signals that interrupt syscalls */ 27 sigset_t ps_oldmask; /* saved mask from before sigpause */ 28 int ps_flags; /* signal flags, below */ 29 struct sigstack ps_sigstack; /* sp & on stack state variable */ 30 int ps_sig; /* for core dump/debugger XXX */ 31 int ps_code; /* for core dump/debugger XXX */ 32 int ps_addr; /* for core dump/debugger XXX */ 33 sigset_t ps_usertramp; /* SunOS compat; libc sigtramp XXX */ 34 }; 35 36 #define ps_onstack ps_sigstack.ss_onstack 37 #define ps_sigsp ps_sigstack.ss_sp 38 39 /* signal flags */ 40 #define SA_OLDMASK 0x01 /* need to restore mask before pause */ 41 42 /* additional signal action values, used only temporarily/internally */ 43 #define SIG_CATCH (void (*)())2 44 #define SIG_HOLD (void (*)())3 45 46 /* 47 * get signal action for process and signal; currently only for current process 48 */ 49 #define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[(sig)]) 50 51 /* 52 * Determine signal that should be delivered to process p, the current process, 53 * 0 if none. If there is a pending stop signal with default action, 54 * the process stops in issig(). 55 */ 56 #define CURSIG(p) \ 57 (((p)->p_sig == 0 || \ 58 ((p)->p_flag&STRC) == 0 && ((p)->p_sig &~ (p)->p_sigmask) == 0) ? \ 59 0 : issig(p)) 60 61 /* 62 * Clear a pending signal from a process. 63 */ 64 #define CLRSIG(p, sig) { (p)->p_sig &= ~sigmask(sig); } 65 66 /* 67 * Signal properties and actions. 68 * The array below categorizes the signals and their default actions 69 * according to the following properties: 70 */ 71 #define SA_KILL 0x01 /* terminates process by default */ 72 #define SA_CORE 0x02 /* ditto and coredumps */ 73 #define SA_STOP 0x04 /* suspend process */ 74 #define SA_TTYSTOP 0x08 /* ditto, from tty */ 75 #define SA_IGNORE 0x10 /* ignore by default */ 76 #define SA_CONT 0x20 /* continue if suspended */ 77 #define SA_CANTMASK 0x40 /* non-maskable, catchable */ 78 79 #ifdef SIGPROP 80 int sigprop[NSIG + 1] = { 81 0, /* unused */ 82 SA_KILL, /* SIGHUP */ 83 SA_KILL, /* SIGINT */ 84 SA_KILL|SA_CORE, /* SIGQUIT */ 85 SA_KILL|SA_CORE, /* SIGILL */ 86 SA_KILL|SA_CORE, /* SIGTRAP */ 87 SA_KILL|SA_CORE, /* SIGABRT */ 88 SA_KILL|SA_CORE, /* SIGEMT */ 89 SA_KILL|SA_CORE, /* SIGFPE */ 90 SA_KILL, /* SIGKILL */ 91 SA_KILL|SA_CORE, /* SIGBUS */ 92 SA_KILL|SA_CORE, /* SIGSEGV */ 93 SA_KILL|SA_CORE, /* SIGSYS */ 94 SA_KILL, /* SIGPIPE */ 95 SA_KILL, /* SIGALRM */ 96 SA_KILL, /* SIGTERM */ 97 SA_IGNORE, /* SIGURG */ 98 SA_STOP, /* SIGSTOP */ 99 SA_STOP|SA_TTYSTOP, /* SIGTSTP */ 100 SA_IGNORE|SA_CONT, /* SIGCONT */ 101 SA_IGNORE, /* SIGCHLD */ 102 SA_STOP|SA_TTYSTOP, /* SIGTTIN */ 103 SA_STOP|SA_TTYSTOP, /* SIGTTOU */ 104 SA_IGNORE, /* SIGIO */ 105 SA_KILL, /* SIGXCPU */ 106 SA_KILL, /* SIGXFSZ */ 107 SA_KILL, /* SIGVTALRM */ 108 SA_KILL, /* SIGPROF */ 109 SA_IGNORE, /* SIGWINCH */ 110 SA_IGNORE, /* SIGINFO */ 111 SA_KILL, /* SIGUSR1 */ 112 SA_KILL, /* SIGUSR2 */ 113 }; 114 115 #define stopsigmask (sigmask(SIGSTOP)|sigmask(SIGTSTP)|\ 116 sigmask(SIGTTIN)|sigmask(SIGTTOU)) 117 #define contsigmask (sigmask(SIGCONT)) 118 119 #endif /* SIGPROP */ 120 121 #define sigcantmask (sigmask(SIGKILL)|sigmask(SIGSTOP)) 122 123 #ifdef KERNEL 124 /* 125 * Machine-independent functions: 126 */ 127 void siginit __P((struct proc *p)); 128 void execsigs __P((struct proc *p)); 129 void gsignal __P((int pgid, int sig)); 130 void pgsignal __P((struct pgrp *pgrp, int sig, int checkctty)); 131 void trapsignal __P((struct proc *p, int sig, unsigned code)); 132 void psignal __P((struct proc *p, int sig)); 133 int issig __P((struct proc *p)); 134 void psig __P((int sig)); 135 int coredump __P((struct proc *p)); 136 137 /* 138 * Machine-dependent functions: 139 */ 140 void sendsig __P((sig_t action, int sig, int returnmask, unsigned code)); 141 #endif /* KERNEL */ 142 #endif /* !_SIGNALVAR_H_ */ 143