1 /* 2 * Copyright (c) 1982, 1986, 1989 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)signal.h 7.14 (Berkeley) 12/16/90 8 */ 9 10 #ifndef NSIG 11 #define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */ 12 13 #ifndef _POSIX_SOURCE 14 #include <machine/trap.h> /* codes for SIGILL, SIGFPE */ 15 #endif /* _POSIX_SOURCE */ 16 17 #define SIGHUP 1 /* hangup */ 18 #define SIGINT 2 /* interrupt */ 19 #define SIGQUIT 3 /* quit */ 20 #define SIGILL 4 /* illegal instruction (not reset when caught) */ 21 #ifndef _POSIX_SOURCE 22 #define SIGTRAP 5 /* trace trap (not reset when caught) */ 23 #endif 24 #define SIGABRT 6 /* abort() */ 25 #ifndef _POSIX_SOURCE 26 #define SIGIOT SIGABRT /* compatibility */ 27 #define SIGEMT 7 /* EMT instruction */ 28 #endif 29 #define SIGFPE 8 /* floating point exception */ 30 #define SIGKILL 9 /* kill (cannot be caught or ignored) */ 31 #ifndef _POSIX_SOURCE 32 #define SIGBUS 10 /* bus error */ 33 #endif 34 #define SIGSEGV 11 /* segmentation violation */ 35 #ifndef _POSIX_SOURCE 36 #define SIGSYS 12 /* bad argument to system call */ 37 #endif 38 #define SIGPIPE 13 /* write on a pipe with no one to read it */ 39 #define SIGALRM 14 /* alarm clock */ 40 #define SIGTERM 15 /* software termination signal from kill */ 41 #ifndef _POSIX_SOURCE 42 #define SIGURG 16 /* urgent condition on IO channel */ 43 #endif 44 #define SIGSTOP 17 /* sendable stop signal not from tty */ 45 #define SIGTSTP 18 /* stop signal from tty */ 46 #define SIGCONT 19 /* continue a stopped process */ 47 #define SIGCHLD 20 /* to parent on child stop or exit */ 48 #define SIGTTIN 21 /* to readers pgrp upon background tty read */ 49 #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ 50 #ifndef _POSIX_SOURCE 51 #define SIGIO 23 /* input/output possible signal */ 52 #define SIGXCPU 24 /* exceeded CPU time limit */ 53 #define SIGXFSZ 25 /* exceeded file size limit */ 54 #define SIGVTALRM 26 /* virtual time alarm */ 55 #define SIGPROF 27 /* profiling time alarm */ 56 #define SIGWINCH 28 /* window size changes */ 57 #define SIGINFO 29 /* information request */ 58 #endif 59 #define SIGUSR1 30 /* user defined signal 1 */ 60 #define SIGUSR2 31 /* user defined signal 2 */ 61 62 #ifndef _POSIX_SOURCE 63 typedef void (*sig_t)(); 64 #endif 65 66 #ifndef KERNEL 67 void (*signal())(); 68 #endif 69 70 typedef unsigned int sigset_t; 71 72 #if __STDC__ || c_plusplus 73 int sigemptyset(sigset_t *); 74 int sigfillset(sigset_t *); 75 int sigaddset(sigset_t *, int); 76 int sigdelset(sigset_t *, int); 77 int sigismember(const sigset_t *, int); 78 #else 79 int sigemptyset(); 80 int sigfillset(); 81 int sigaddset(); 82 int sigdelset(); 83 int sigismember(); 84 #endif 85 86 #define sigemptyset(set) ( *(set) = 0 ) 87 #define sigfillset(set) ( *(set) = ~(sigset_t)0, 0 ) 88 #define sigaddset(set, signo) ( *(set) |= 1 << ((signo) - 1), 0) 89 #define sigdelset(set, signo) ( *(set) &= ~(1 << ((signo) - 1)), 0) 90 #define sigismember(set, signo) ( (*(set) & (1 << ((signo) - 1))) != 0) 91 92 /* 93 * Signal vector "template" used in sigaction call. 94 */ 95 struct sigaction { 96 void (*sa_handler)(); /* signal handler */ 97 sigset_t sa_mask; /* signal mask to apply */ 98 int sa_flags; /* see signal options below */ 99 }; 100 #ifndef _POSIX_SOURCE 101 #define SA_ONSTACK 0x0001 /* take signal on signal stack */ 102 #define SA_RESTART 0x0002 /* do not restart system on signal return */ 103 #endif 104 #define SA_NOCLDSTOP 0x0004 /* do not generate SIGCHLD on child stop */ 105 106 /* 107 * Flags for sigprocmask: 108 */ 109 #define SIG_BLOCK 1 /* block specified signal set */ 110 #define SIG_UNBLOCK 2 /* unblock specified signal set */ 111 #define SIG_SETMASK 3 /* set specified signal set */ 112 113 #ifndef _POSIX_SOURCE 114 /* 115 * 4.3 compatibility: 116 * Signal vector "template" used in sigvec call. 117 */ 118 struct sigvec { 119 void (*sv_handler)(); /* signal handler */ 120 int sv_mask; /* signal mask to apply */ 121 int sv_flags; /* see signal options below */ 122 }; 123 #define SV_ONSTACK SA_ONSTACK 124 #define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */ 125 #define sv_onstack sv_flags /* isn't compatibility wonderful! */ 126 127 /* 128 * Structure used in sigstack call. 129 */ 130 struct sigstack { 131 char *ss_sp; /* signal stack pointer */ 132 int ss_onstack; /* current status */ 133 }; 134 135 /* 136 * Information pushed on stack when a signal is delivered. 137 * This is used by the kernel to restore state following 138 * execution of the signal handler. It is also made available 139 * to the handler to allow it to restore state properly if 140 * a non-standard exit is performed. 141 */ 142 struct sigcontext { 143 int sc_onstack; /* sigstack state to restore */ 144 int sc_mask; /* signal mask to restore */ 145 int sc_sp; /* sp to restore */ 146 int sc_fp; /* fp to restore */ 147 int sc_ap; /* ap to restore */ 148 int sc_pc; /* pc to restore */ 149 int sc_ps; /* psl to restore */ 150 }; 151 152 /* 153 * Macro for converting signal number to a mask suitable for 154 * sigblock(). 155 */ 156 #define sigmask(m) (1 << ((m)-1)) 157 158 #define BADSIG (void (*)())-1 159 #endif /* _POSIX_SOURCE */ 160 161 #define SIG_DFL (void (*)())0 162 #define SIG_IGN (void (*)())1 163 164 #ifdef KERNEL 165 #define SIG_CATCH (void (*)())2 166 #define SIG_HOLD (void (*)())3 167 168 #define sigcantmask (sigmask(SIGKILL)|sigmask(SIGSTOP)) 169 /* 170 * get signal action for process and signal; currently only for current process 171 */ 172 #define SIGACTION(p, sig) (u.u_signal[(sig)]) 173 174 /* 175 * Determine signal that should be delivered to process p, the current process, 176 * 0 if none. If there is a pending stop signal with default action, 177 * the process stops in issig(). 178 */ 179 #define CURSIG(p) \ 180 (((p)->p_sig == 0 || \ 181 ((p)->p_flag&STRC) == 0 && ((p)->p_sig &~ (p)->p_sigmask) == 0) ? \ 182 0 : issig()) 183 184 /* 185 * Clear a pending signal from a process. 186 */ 187 #define CLRSIG(p, sig) { (p)->p_sig &= ~sigmask(sig); } 188 189 #endif /* KERNEL */ 190 191 #ifndef KERNEL 192 #if __STDC__ || c_plusplus 193 #include <sys/types.h> 194 int kill(pid_t, int); 195 int sigaction(int, const struct sigaction *, struct sigaction *); 196 int sigprocmask(int, const sigset_t *, sigset_t *); 197 int sigpending(sigset_t *); 198 int sigsuspend(const sigset_t *); 199 #else 200 int kill(); 201 int sigaction(); 202 int sigprocmask(); 203 int sigpending(); 204 int sigsuspend(); 205 #endif 206 #endif 207 #endif /* NSIG */ 208