1 /* 2 * Copyright (c) 1982, 1986, 1989, 1991 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)signal.h 7.26 (Berkeley) 03/28/93 8 */ 9 10 #ifndef _SYS_SIGNAL_H_ 11 #define _SYS_SIGNAL_H_ 12 13 #define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */ 14 15 #ifndef _ANSI_SOURCE 16 #include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */ 17 #endif 18 19 #define SIGHUP 1 /* hangup */ 20 #define SIGINT 2 /* interrupt */ 21 #define SIGQUIT 3 /* quit */ 22 #define SIGILL 4 /* illegal instruction (not reset when caught) */ 23 #ifndef _POSIX_SOURCE 24 #define SIGTRAP 5 /* trace trap (not reset when caught) */ 25 #endif 26 #define SIGABRT 6 /* abort() */ 27 #ifndef _POSIX_SOURCE 28 #define SIGIOT SIGABRT /* compatibility */ 29 #define SIGEMT 7 /* EMT instruction */ 30 #endif 31 #define SIGFPE 8 /* floating point exception */ 32 #define SIGKILL 9 /* kill (cannot be caught or ignored) */ 33 #ifndef _POSIX_SOURCE 34 #define SIGBUS 10 /* bus error */ 35 #endif 36 #define SIGSEGV 11 /* segmentation violation */ 37 #ifndef _POSIX_SOURCE 38 #define SIGSYS 12 /* bad argument to system call */ 39 #endif 40 #define SIGPIPE 13 /* write on a pipe with no one to read it */ 41 #define SIGALRM 14 /* alarm clock */ 42 #define SIGTERM 15 /* software termination signal from kill */ 43 #ifndef _POSIX_SOURCE 44 #define SIGURG 16 /* urgent condition on IO channel */ 45 #endif 46 #define SIGSTOP 17 /* sendable stop signal not from tty */ 47 #define SIGTSTP 18 /* stop signal from tty */ 48 #define SIGCONT 19 /* continue a stopped process */ 49 #define SIGCHLD 20 /* to parent on child stop or exit */ 50 #define SIGTTIN 21 /* to readers pgrp upon background tty read */ 51 #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ 52 #ifndef _POSIX_SOURCE 53 #define SIGIO 23 /* input/output possible signal */ 54 #define SIGXCPU 24 /* exceeded CPU time limit */ 55 #define SIGXFSZ 25 /* exceeded file size limit */ 56 #define SIGVTALRM 26 /* virtual time alarm */ 57 #define SIGPROF 27 /* profiling time alarm */ 58 #define SIGWINCH 28 /* window size changes */ 59 #define SIGINFO 29 /* information request */ 60 #endif 61 #define SIGUSR1 30 /* user defined signal 1 */ 62 #define SIGUSR2 31 /* user defined signal 2 */ 63 64 #if defined(_ANSI_SOURCE) || defined(__cplusplus) 65 /* 66 * Language spec sez we must list exactly one parameter, even though we 67 * actually supply three. Ugh! 68 */ 69 #define SIG_DFL (void (*)(int))0 70 #define SIG_IGN (void (*)(int))1 71 #define SIG_ERR (void (*)(int))-1 72 #else 73 #define SIG_DFL (void (*)())0 74 #define SIG_IGN (void (*)())1 75 #define SIG_ERR (void (*)())-1 76 #endif 77 78 #ifndef _ANSI_SOURCE 79 typedef unsigned int sigset_t; 80 81 /* 82 * Signal vector "template" used in sigaction call. 83 */ 84 struct sigaction { 85 void (*sa_handler)(); /* signal handler */ 86 sigset_t sa_mask; /* signal mask to apply */ 87 int sa_flags; /* see signal options below */ 88 }; 89 #ifndef _POSIX_SOURCE 90 #define SA_ONSTACK 0x0001 /* take signal on signal stack */ 91 #define SA_RESTART 0x0002 /* restart system on signal return */ 92 #define SA_DISABLE 0x0004 /* disable taking signals on alternate stack */ 93 #ifdef COMPAT_SUNOS 94 #define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */ 95 #endif 96 #endif 97 #define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */ 98 99 /* 100 * Flags for sigprocmask: 101 */ 102 #define SIG_BLOCK 1 /* block specified signal set */ 103 #define SIG_UNBLOCK 2 /* unblock specified signal set */ 104 #define SIG_SETMASK 3 /* set specified signal set */ 105 106 #ifndef _POSIX_SOURCE 107 #ifndef KERNEL 108 #include <sys/cdefs.h> 109 #endif 110 typedef void (*sig_t) __P((int)); /* type of signal function */ 111 112 /* 113 * Structure used in sigaltstack call. 114 */ 115 struct sigaltstack { 116 char *ss_base; /* signal stack base */ 117 int ss_size; /* signal stack length */ 118 int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */ 119 }; 120 #define MINSIGSTKSZ 8192 /* minimum allowable stack */ 121 #define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */ 122 123 /* 124 * 4.3 compatibility: 125 * Signal vector "template" used in sigvec call. 126 */ 127 struct sigvec { 128 void (*sv_handler)(); /* signal handler */ 129 int sv_mask; /* signal mask to apply */ 130 int sv_flags; /* see signal options below */ 131 }; 132 133 #define SV_ONSTACK SA_ONSTACK 134 #define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */ 135 #define sv_onstack sv_flags /* isn't compatibility wonderful! */ 136 137 /* 138 * Structure used in sigstack call. 139 */ 140 struct sigstack { 141 char *ss_sp; /* signal stack pointer */ 142 int ss_onstack; /* current status */ 143 }; 144 145 /* 146 * Macro for converting signal number to a mask suitable for 147 * sigblock(). 148 */ 149 #define sigmask(m) (1 << ((m)-1)) 150 151 #define BADSIG SIG_ERR 152 153 #endif /* !_POSIX_SOURCE */ 154 #endif /* !_ANSI_SOURCE */ 155 156 /* 157 * For historical reasons; programs expect signal's return value to be 158 * defined by <sys/signal.h>. 159 */ 160 __BEGIN_DECLS 161 void (*signal __P((int, void (*) __P((int))))) __P((int)); 162 __END_DECLS 163 #endif /* !_SYS_SIGNAL_H_ */ 164