1 /** $MirOS: src/sys/sys/signal.h,v 1.3 2005/07/07 14:39:27 tg Exp $ */ 2 /* $OpenBSD: signal.h,v 1.17 2005/05/24 18:06:10 millert Exp $ */ 3 /* $NetBSD: signal.h,v 1.21 1996/02/09 18:25:32 christos Exp $ */ 4 5 /* 6 * Copyright (c) 1982, 1986, 1989, 1991, 1993 7 * The Regents of the University of California. All rights reserved. 8 * (c) UNIX System Laboratories, Inc. 9 * All or some portions of this file are derived from material licensed 10 * to the University of California by American Telephone and Telegraph 11 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 12 * the permission of UNIX System Laboratories, Inc. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions 16 * are met: 17 * 1. Redistributions of source code must retain the above copyright 18 * notice, this list of conditions and the following disclaimer. 19 * 2. Redistributions in binary form must reproduce the above copyright 20 * notice, this list of conditions and the following disclaimer in the 21 * documentation and/or other materials provided with the distribution. 22 * 3. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)signal.h 8.2 (Berkeley) 1/21/94 39 */ 40 41 #ifndef _SYS_SIGNAL_H_ 42 #define _SYS_SIGNAL_H_ 43 44 #include <sys/cdefs.h> 45 #include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */ 46 47 #define _NSIG 32 /* counting 0; could be 33 (mask is 1-32) */ 48 49 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 50 #define NSIG _NSIG 51 #endif 52 53 #define SIGHUP 1 /* hangup */ 54 #define SIGINT 2 /* interrupt */ 55 #define SIGQUIT 3 /* quit */ 56 #define SIGILL 4 /* illegal instruction (not reset when caught) */ 57 #define SIGTRAP 5 /* trace trap (not reset when caught) */ 58 #define SIGABRT 6 /* abort() */ 59 #ifndef _POSIX_SOURCE 60 #define SIGIOT SIGABRT /* compatibility */ 61 #define SIGEMT 7 /* EMT instruction */ 62 #endif 63 #define SIGFPE 8 /* floating point exception */ 64 #define SIGKILL 9 /* kill (cannot be caught or ignored) */ 65 #define SIGBUS 10 /* bus error */ 66 #define SIGSEGV 11 /* segmentation violation */ 67 #define SIGSYS 12 /* bad argument to system call */ 68 #define SIGPIPE 13 /* write on a pipe with no one to read it */ 69 #define SIGALRM 14 /* alarm clock */ 70 #define SIGTERM 15 /* software termination signal from kill */ 71 #define SIGURG 16 /* urgent condition on IO channel */ 72 #define SIGSTOP 17 /* sendable stop signal not from tty */ 73 #define SIGTSTP 18 /* stop signal from tty */ 74 #define SIGCONT 19 /* continue a stopped process */ 75 #define SIGCHLD 20 /* to parent on child stop or exit */ 76 #define SIGTTIN 21 /* to readers pgrp upon background tty read */ 77 #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ 78 #ifndef _POSIX_SOURCE 79 #define SIGIO 23 /* input/output possible signal */ 80 #endif 81 #define SIGXCPU 24 /* exceeded CPU time limit */ 82 #define SIGXFSZ 25 /* exceeded file size limit */ 83 #define SIGVTALRM 26 /* virtual time alarm */ 84 #define SIGPROF 27 /* profiling time alarm */ 85 #ifndef _POSIX_SOURCE 86 #define SIGWINCH 28 /* window size changes */ 87 #define SIGINFO 29 /* information request */ 88 #endif 89 #define SIGUSR1 30 /* user defined signal 1 */ 90 #define SIGUSR2 31 /* user defined signal 2 */ 91 92 /* 93 * Language spec says we must list exactly one parameter, even though we 94 * actually supply three. Ugh! 95 */ 96 #define SIG_DFL (void (*)(int))0 97 #define SIG_IGN (void (*)(int))1 98 #define SIG_ERR (void (*)(int))-1 99 100 #ifndef _ANSI_SOURCE 101 typedef unsigned int sigset_t; 102 103 #include <sys/siginfo.h> 104 105 /* 106 * Signal vector "template" used in sigaction call. 107 */ 108 struct sigaction { 109 union { /* signal handler */ 110 void (*__sa_handler)(int); 111 void (*__sa_sigaction)(int, siginfo_t *, void *); 112 } __sigaction_u; 113 sigset_t sa_mask; /* signal mask to apply */ 114 int sa_flags; /* see signal options below */ 115 }; 116 117 /* if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. */ 118 #define sa_handler __sigaction_u.__sa_handler 119 #define sa_sigaction __sigaction_u.__sa_sigaction 120 121 #ifndef _POSIX_SOURCE 122 #define SA_ONSTACK 0x0001 /* take signal on signal stack */ 123 #define SA_RESTART 0x0002 /* restart system on signal return */ 124 #define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */ 125 #define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */ 126 #define SA_NOCLDWAIT 0x0020 /* don't create zombies (assign to pid 1) */ 127 #endif 128 #define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */ 129 #define SA_SIGINFO 0x0040 /* generate siginfo_t */ 130 131 /* 132 * Flags for sigprocmask: 133 */ 134 #define SIG_BLOCK 1 /* block specified signal set */ 135 #define SIG_UNBLOCK 2 /* unblock specified signal set */ 136 #define SIG_SETMASK 3 /* set specified signal set */ 137 138 #ifndef _POSIX_SOURCE 139 typedef void (*sig_t)(int); /* type of signal function */ 140 141 /* 142 * Structure used in sigaltstack call. 143 */ 144 typedef struct sigaltstack { 145 void *ss_sp; /* signal stack base */ 146 size_t ss_size; /* signal stack length */ 147 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ 148 } stack_t; 149 #define SS_ONSTACK 0x0001 /* take signals on alternate stack */ 150 #define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */ 151 #define MINSIGSTKSZ 8192 /* minimum allowable stack */ 152 #define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */ 153 154 #ifdef _KERNEL 155 struct osigaltstack { 156 void *ss_sp; /* signal stack base */ 157 int ss_size; /* signal stack length */ 158 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ 159 }; 160 #endif 161 162 /* 163 * 4.3 compatibility: 164 * Signal vector "template" used in sigvec call. 165 */ 166 struct sigvec { 167 void (*sv_handler)(int); /* signal handler */ 168 int sv_mask; /* signal mask to apply */ 169 int sv_flags; /* see signal options below */ 170 }; 171 #define SV_ONSTACK SA_ONSTACK 172 #define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */ 173 #define SV_RESETHAND SA_RESETHAND 174 #define sv_onstack sv_flags /* isn't compatibility wonderful! */ 175 176 /* 177 * Structure used in sigstack call. 178 */ 179 struct sigstack { 180 void *ss_sp; /* signal stack pointer */ 181 int ss_onstack; /* current status */ 182 }; 183 184 typedef struct sigcontext ucontext_t; 185 186 /* 187 * Macro for converting signal number to a mask suitable for 188 * sigblock(). 189 */ 190 #define sigmask(m) (1 << ((m)-1)) 191 192 #define BADSIG SIG_ERR 193 194 #endif /* !_POSIX_SOURCE */ 195 #endif /* !_ANSI_SOURCE */ 196 197 /* 198 * For historical reasons; programs expect signal's return value to be 199 * defined by <sys/signal.h>. 200 */ 201 __BEGIN_DECLS 202 void (*signal(int, void (*)(int)))(int); 203 __END_DECLS 204 #endif /* !_SYS_SIGNAL_H_ */ 205