signalvar.h revision 1542
161765Smjacob/* 2139749Simp * Copyright (c) 1991, 1993 372345Smjacob * The Regents of the University of California. All rights reserved. 461765Smjacob * 561765Smjacob * Redistribution and use in source and binary forms, with or without 661765Smjacob * modification, are permitted provided that the following conditions 761765Smjacob * are met: 861765Smjacob * 1. Redistributions of source code must retain the above copyright 961765Smjacob * notice, this list of conditions and the following disclaimer. 1061765Smjacob * 2. Redistributions in binary form must reproduce the above copyright 1161765Smjacob * notice, this list of conditions and the following disclaimer in the 1261765Smjacob * documentation and/or other materials provided with the distribution. 1361765Smjacob * 3. All advertising materials mentioning features or use of this software 1461765Smjacob * must display the following acknowledgement: 1561765Smjacob * This product includes software developed by the University of 1661765Smjacob * California, Berkeley and its contributors. 1761765Smjacob * 4. Neither the name of the University nor the names of its contributors 1861765Smjacob * may be used to endorse or promote products derived from this software 1961765Smjacob * without specific prior written permission. 2061765Smjacob * 2161765Smjacob * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2261765Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2361765Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2461765Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2561765Smjacob * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2661765Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2761765Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2861765Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2961765Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3061765Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3161765Smjacob * SUCH DAMAGE. 3261765Smjacob * 3361765Smjacob * @(#)signalvar.h 8.3 (Berkeley) 1/4/94 3461765Smjacob */ 3572345Smjacob 3661765Smjacob#ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */ 37160212Smjacob#define _SYS_SIGNALVAR_H_ 3861765Smjacob 3972345Smjacob/* 4061765Smjacob * Kernel signal definitions and data structures, 4161765Smjacob * not exported to user programs. 4261765Smjacob */ 4361765Smjacob 4472345Smjacob/* 4561765Smjacob * Process signal actions and state, needed only within the process 4661765Smjacob * (not necessarily resident). 4761765Smjacob */ 4861765Smjacobstruct sigacts { 4961765Smjacob sig_t ps_sigact[NSIG]; /* disposition of signals */ 5061765Smjacob sigset_t ps_catchmask[NSIG]; /* signals to be blocked */ 5161765Smjacob sigset_t ps_sigonstack; /* signals to take on sigstack */ 5261765Smjacob sigset_t ps_sigintr; /* signals that interrupt syscalls */ 5361765Smjacob sigset_t ps_oldmask; /* saved mask from before sigpause */ 5461765Smjacob int ps_flags; /* signal flags, below */ 5561765Smjacob struct sigaltstack ps_sigstk; /* sp & on stack state variable */ 5661765Smjacob int ps_sig; /* for core dump/debugger XXX */ 5761765Smjacob int ps_code; /* for core dump/debugger XXX */ 5861765Smjacob int ps_addr; /* for core dump/debugger XXX */ 5961765Smjacob sigset_t ps_usertramp; /* SunOS compat; libc sigtramp XXX */ 6061765Smjacob}; 6161765Smjacob 6261765Smjacob/* signal flags */ 6361765Smjacob#define SAS_OLDMASK 0x01 /* need to restore mask before pause */ 6461765Smjacob#define SAS_ALTSTACK 0x02 /* have alternate signal stack */ 6561765Smjacob 6672345Smjacob/* additional signal action values, used only temporarily/internally */ 6761765Smjacob#define SIG_CATCH (void (*)())2 6861765Smjacob#define SIG_HOLD (void (*)())3 6961765Smjacob 7061765Smjacob/* 7161765Smjacob * get signal action for process and signal; currently only for current process 7261765Smjacob */ 7361765Smjacob#define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[(sig)]) 7461765Smjacob 7561765Smjacob/* 7661765Smjacob * Determine signal that should be delivered to process p, the current 7761765Smjacob * process, 0 if none. If there is a pending stop signal with default 7861765Smjacob * action, the process stops in issig(). 7961765Smjacob */ 8061765Smjacob#define CURSIG(p) \ 8161765Smjacob (((p)->p_siglist == 0 || \ 8272345Smjacob ((p)->p_flag & P_TRACED) == 0 && \ 8361765Smjacob ((p)->p_siglist & ~(p)->p_sigmask) == 0) ? \ 8461765Smjacob 0 : issignal(p)) 8572345Smjacob 8672345Smjacob/* 8772345Smjacob * Clear a pending signal from a process. 8872345Smjacob */ 8961765Smjacob#define CLRSIG(p, sig) { (p)->p_siglist &= ~sigmask(sig); } 9061765Smjacob 9161765Smjacob/* 9261765Smjacob * Signal properties and actions. 9361765Smjacob * The array below categorizes the signals and their default actions 9461765Smjacob * according to the following properties: 9561765Smjacob */ 9661765Smjacob#define SA_KILL 0x01 /* terminates process by default */ 9761765Smjacob#define SA_CORE 0x02 /* ditto and coredumps */ 9861765Smjacob#define SA_STOP 0x04 /* suspend process */ 9961765Smjacob#define SA_TTYSTOP 0x08 /* ditto, from tty */ 10072345Smjacob#define SA_IGNORE 0x10 /* ignore by default */ 10172345Smjacob#define SA_CONT 0x20 /* continue if suspended */ 10272345Smjacob#define SA_CANTMASK 0x40 /* non-maskable, catchable */ 10372345Smjacob 10472345Smjacob#ifdef SIGPROP 10561765Smjacobint sigprop[NSIG + 1] = { 10661765Smjacob 0, /* unused */ 10761765Smjacob SA_KILL, /* SIGHUP */ 10861765Smjacob SA_KILL, /* SIGINT */ 10961765Smjacob SA_KILL|SA_CORE, /* SIGQUIT */ 11072345Smjacob SA_KILL|SA_CORE, /* SIGILL */ 11172345Smjacob SA_KILL|SA_CORE, /* SIGTRAP */ 11272345Smjacob SA_KILL|SA_CORE, /* SIGABRT */ 11372345Smjacob SA_KILL|SA_CORE, /* SIGEMT */ 11472345Smjacob SA_KILL|SA_CORE, /* SIGFPE */ 11572345Smjacob SA_KILL, /* SIGKILL */ 11672345Smjacob SA_KILL|SA_CORE, /* SIGBUS */ 11772345Smjacob SA_KILL|SA_CORE, /* SIGSEGV */ 11872345Smjacob SA_KILL|SA_CORE, /* SIGSYS */ 11972345Smjacob SA_KILL, /* SIGPIPE */ 12072345Smjacob SA_KILL, /* SIGALRM */ 12172345Smjacob SA_KILL, /* SIGTERM */ 12272345Smjacob SA_IGNORE, /* SIGURG */ 12361765Smjacob SA_STOP, /* SIGSTOP */ 12461765Smjacob SA_STOP|SA_TTYSTOP, /* SIGTSTP */ 12561765Smjacob SA_IGNORE|SA_CONT, /* SIGCONT */ 12661765Smjacob SA_IGNORE, /* SIGCHLD */ 12761765Smjacob SA_STOP|SA_TTYSTOP, /* SIGTTIN */ 12861765Smjacob SA_STOP|SA_TTYSTOP, /* SIGTTOU */ 12961765Smjacob SA_IGNORE, /* SIGIO */ 13061765Smjacob SA_KILL, /* SIGXCPU */ 13161765Smjacob SA_KILL, /* SIGXFSZ */ 13261765Smjacob SA_KILL, /* SIGVTALRM */ 13372345Smjacob SA_KILL, /* SIGPROF */ 13461765Smjacob SA_IGNORE, /* SIGWINCH */ 13561765Smjacob SA_IGNORE, /* SIGINFO */ 13661765Smjacob SA_KILL, /* SIGUSR1 */ 13761765Smjacob SA_KILL, /* SIGUSR2 */ 13861765Smjacob}; 13961765Smjacob 14061765Smjacob#define contsigmask (sigmask(SIGCONT)) 14161765Smjacob#define stopsigmask (sigmask(SIGSTOP) | sigmask(SIGTSTP) | \ 14261765Smjacob sigmask(SIGTTIN) | sigmask(SIGTTOU)) 14361765Smjacob 14461765Smjacob#endif /* SIGPROP */ 14561765Smjacob 14672345Smjacob#define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP)) 14761765Smjacob 14861765Smjacob#ifdef KERNEL 14972345Smjacob/* 15072345Smjacob * Machine-independent functions: 15161765Smjacob */ 15261765Smjacobint coredump __P((struct proc *p)); 15372345Smjacobvoid execsigs __P((struct proc *p)); 15472345Smjacobvoid gsignal __P((int pgid, int sig)); 15572345Smjacobint issig __P((struct proc *p)); 15672345Smjacobvoid pgsignal __P((struct pgrp *pgrp, int sig, int checkctty)); 15772345Smjacobvoid postsig __P((int sig)); 15872345Smjacobvoid psignal __P((struct proc *p, int sig)); 15972345Smjacobvoid siginit __P((struct proc *p)); 16072345Smjacobvoid trapsignal __P((struct proc *p, int sig, unsigned code)); 16172345Smjacob 16272345Smjacob/* 16372345Smjacob * Machine-dependent functions: 16472345Smjacob */ 16572345Smjacobvoid sendsig __P((sig_t action, int sig, int returnmask, unsigned code)); 16672345Smjacob#endif /* KERNEL */ 16772345Smjacob#endif /* !_SYS_SIGNALVAR_H_ */ 16872345Smjacob