kernel: some boottime sanitychecks
[minix.git] / include / sys / signal.h
blobf9bc91f37c2c10f4ca96d811e02924fc5b6f9705
1 #ifndef _SYS_SIGNAL_H_
2 #define _SYS_SIGNAL_H_
4 #include <sys/featuretest.h>
5 #include <sys/sigtypes.h>
7 #define _NSIG 26
8 #define NSIG _NSIG
11 /* Regular signals. */
12 #define SIGHUP 1 /* hangup */
13 #define SIGINT 2 /* interrupt (DEL) */
14 #define SIGQUIT 3 /* quit (ASCII FS) */
15 #define SIGILL 4 /* illegal instruction */
16 #define SIGTRAP 5 /* trace trap (not reset when caught) */
17 #define SIGABRT 6 /* IOT instruction */
18 #define SIGBUS 7 /* bus error */
19 #define SIGFPE 8 /* floating point exception */
20 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
21 #define SIGUSR1 10 /* user defined signal # 1 */
22 #define SIGSEGV 11 /* segmentation violation */
23 #define SIGUSR2 12 /* user defined signal # 2 */
24 #define SIGPIPE 13 /* write on a pipe with no one to read it */
25 #define SIGALRM 14 /* alarm clock */
26 #define SIGTERM 15 /* software termination signal from kill */
27 #define SIGEMT 16 /* EMT instruction */
28 #define SIGCHLD 17 /* child process terminated or stopped */
29 #define SIGWINCH 21 /* window size has changed */
30 #define SIGVTALRM 24 /* virtual alarm */
31 #define SIGPROF 25 /* profiler alarm */
33 /* POSIX requires the following signals to be defined, even if they are
34 * not supported. Here are the definitions, but they are not supported.
36 #define SIGCONT 18 /* continue if stopped */
37 #define SIGSTOP 19 /* stop signal */
38 #define SIGTSTP 20 /* interactive stop signal */
39 #define SIGTTIN 22 /* background process wants to read */
40 #define SIGTTOU 23 /* background process wants to write */
42 #ifdef _MINIX
43 #define SIGIOT SIGABRT /* for people who speak PDP-11 */
45 /* MINIX specific signals. These signals are not used by user proceses,
46 * but meant to inform system processes, like the PM, about system events.
47 * The order here determines the order signals are processed by system
48 * processes in user-space. Higher-priority signals should be first.
50 /* Signals delivered by a signal manager. */
51 #define SIGSNDELAY 26 /* end of delay for signal delivery */
53 #define SIGS_FIRST SIGHUP /* first system signal */
54 #define SIGS_LAST SIGSNDELAY /* last system signal */
55 #define IS_SIGS(signo) (signo>=SIGS_FIRST && signo<=SIGS_LAST)
57 /* Signals delivered by the kernel. */
58 #define SIGKMEM 27 /* kernel memory request pending */
59 #define SIGKMESS 28 /* new kernel message */
60 #define SIGKSIGSM 29 /* kernel signal pending for signal manager */
61 #define SIGKSIG 30 /* kernel signal pending */
63 #define SIGK_FIRST SIGKMEM /* first kernel signal */
64 #define SIGK_LAST SIGKSIG /* last kernel signal */
65 #define IS_SIGK(signo) (signo>=SIGK_FIRST && signo<=SIGK_LAST)
67 /* Termination signals for Minix system processes. */
68 #define SIGS_IS_LETHAL(sig) \
69 (sig == SIGILL || sig == SIGBUS || sig == SIGFPE || sig == SIGSEGV \
70 || sig == SIGEMT || sig == SIGABRT)
71 #define SIGS_IS_TERMINATION(sig) (SIGS_IS_LETHAL(sig) \
72 || (sig == SIGKILL || sig == SIGPIPE))
73 #define SIGS_IS_STACKTRACE(sig) (SIGS_IS_LETHAL(sig) && sig != SIGABRT)
75 #endif
77 #include <sys/cdefs.h>
79 typedef void (*__sighandler_t)(int);
81 /* Macros used as function pointers. */
82 #define SIG_ERR ((__sighandler_t) -1) /* error return */
83 #define SIG_DFL ((__sighandler_t) 0) /* default signal handling */
84 #define SIG_IGN ((__sighandler_t) 1) /* ignore signal */
85 #define SIG_HOLD ((__sighandler_t) 2) /* block signal */
86 #define SIG_CATCH ((__sighandler_t) 3) /* catch signal */
88 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
89 defined(_NETBSD_SOURCE)
91 #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
92 defined(_NETBSD_SOURCE)
93 #include <sys/siginfo.h>
94 #endif
96 #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
97 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
98 #include <sys/ucontext.h>
99 #endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
102 * Signal vector "template" used in sigaction call.
104 struct sigaction {
105 union {
106 void (*_sa_handler)(int);
107 #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
108 defined(_NETBSD_SOURCE)
109 void (*_sa_sigaction)(int, siginfo_t *, void *);
110 #endif
111 } _sa_u; /* signal handler */
112 sigset_t sa_mask; /* signal mask to apply */
113 int sa_flags; /* see signal options below */
116 #define sa_handler _sa_u._sa_handler
117 #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
118 defined(_NETBSD_SOURCE)
119 #define sa_sigaction _sa_u._sa_sigaction
120 #endif
122 #include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */
124 /* Fields for sa_flags. */
125 #define SA_ONSTACK 0x0001 /* deliver signal on alternate stack */
126 #define SA_RESETHAND 0x0002 /* reset signal handler when signal caught */
127 #define SA_NODEFER 0x0004 /* don't block signal while catching it */
128 #define SA_RESTART 0x0008 /* automatic system call restart */
129 #define SA_SIGINFO 0x0010 /* extended signal handling */
130 #define SA_NOCLDWAIT 0x0020 /* don't create zombies */
131 #define SA_NOCLDSTOP 0x0040 /* don't receive SIGCHLD when child stops */
133 /* POSIX requires these values for use with sigprocmask(2). */
134 #define SIG_BLOCK 0 /* for blocking signals */
135 #define SIG_UNBLOCK 1 /* for unblocking signals */
136 #define SIG_SETMASK 2 /* for setting the signal mask */
137 #define SIG_INQUIRE 4 /* for internal use only */
139 #if defined(_NETBSD_SOURCE)
140 typedef void (*sig_t)(int); /* type of signal function */
141 #endif
143 #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
144 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
146 * Flags used with stack_t/struct sigaltstack.
148 #define SS_ONSTACK 1 /* Process is executing on an alternate stack */
149 #define SS_DISABLE 2 /* Alternate stack is disabled */
151 #define MINSIGSTKSZ 2048 /* Minimal stack size is 2k */
152 #define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */
153 #endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
155 #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
156 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
158 * Structure used in sigstack call.
160 struct sigstack {
161 void *ss_sp; /* signal stack pointer */
162 int ss_onstack; /* current status */
164 #endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
166 #if defined(_NETBSD_SOURCE) && !defined(_KERNEL)
168 * Macro for converting signal number to a mask suitable for
169 * sigblock().
171 #define sigmask(n) __sigmask(n)
173 #define BADSIG SIG_ERR
174 #endif /* _NETBSD_SOURCE */
176 #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
177 defined(_NETBSD_SOURCE)
178 struct sigevent {
179 int sigev_notify;
180 int sigev_signo;
181 union sigval sigev_value;
182 void (*sigev_notify_function)(union sigval);
183 void /* pthread_attr_t */ *sigev_notify_attributes;
186 #define SIGEV_NONE 0
187 #define SIGEV_SIGNAL 1
188 #define SIGEV_THREAD 2
189 #if defined(_NETBSD_SOURCE)
190 #define SIGEV_SA 3
191 #endif
192 #endif /* (_POSIX_C_SOURCE - 0) >= 199309L || ... */
194 #endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */
197 * For historical reasons; programs expect signal's return value to be
198 * defined by <sys/signal.h>.
200 __BEGIN_DECLS
201 void (*signal(int, void (*)(int)))(int);
202 __END_DECLS
203 #endif /* !_SYS_SIGNAL_H_ */