1 /* The <signal.h> header defines all the ANSI and POSIX signals.
2 * MINIX supports all the signals required by POSIX. They are defined below.
3 * Some additional signals are also supported.
14 #include <minix/types.h>
18 /* Here are types that are closely associated with signal handling. */
19 typedef int sig_atomic_t;
24 typedef unsigned long sigset_t
;
28 /* Regular signals. */
29 #define SIGHUP 1 /* hangup */
30 #define SIGINT 2 /* interrupt (DEL) */
31 #define SIGQUIT 3 /* quit (ASCII FS) */
32 #define SIGILL 4 /* illegal instruction */
33 #define SIGTRAP 5 /* trace trap (not reset when caught) */
34 #define SIGABRT 6 /* IOT instruction */
35 #define SIGBUS 7 /* bus error */
36 #define SIGFPE 8 /* floating point exception */
37 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
38 #define SIGUSR1 10 /* user defined signal # 1 */
39 #define SIGSEGV 11 /* segmentation violation */
40 #define SIGUSR2 12 /* user defined signal # 2 */
41 #define SIGPIPE 13 /* write on a pipe with no one to read it */
42 #define SIGALRM 14 /* alarm clock */
43 #define SIGTERM 15 /* software termination signal from kill */
44 #define SIGEMT 16 /* EMT instruction */
45 #define SIGCHLD 17 /* child process terminated or stopped */
46 #define SIGWINCH 21 /* window size has changed */
47 #define SIGVTALRM 24 /* virtual alarm */
48 #define SIGPROF 25 /* profiler alarm */
50 /* POSIX requires the following signals to be defined, even if they are
51 * not supported. Here are the definitions, but they are not supported.
53 #define SIGCONT 18 /* continue if stopped */
54 #define SIGSTOP 19 /* stop signal */
55 #define SIGTSTP 20 /* interactive stop signal */
56 #define SIGTTIN 22 /* background process wants to read */
57 #define SIGTTOU 23 /* background process wants to write */
59 #define _NSIG 26 /* highest signal number plus one */
63 #define SIGIOT SIGABRT /* for people who speak PDP-11 */
65 /* MINIX specific signals. These signals are not used by user proceses,
66 * but meant to inform system processes, like the PM, about system events.
67 * The order here determines the order signals are processed by system
68 * processes in user-space. Higher-priority signals should be first.
70 /* Signals delivered by a signal manager. */
71 #define SIGSNDELAY 26 /* end of delay for signal delivery */
73 #define SIGS_FIRST SIGHUP /* first system signal */
74 #define SIGS_LAST SIGSNDELAY /* last system signal */
75 #define IS_SIGS(signo) (signo>=SIGS_FIRST && signo<=SIGS_LAST)
77 /* Signals delivered by the kernel. */
78 #define SIGKMEM 27 /* kernel memory request pending */
79 #define SIGKMESS 28 /* new kernel message */
80 #define SIGKSIGSM 29 /* kernel signal pending for signal manager */
81 #define SIGKSIG 30 /* kernel signal pending */
83 #define SIGK_FIRST SIGKMEM /* first kernel signal */
84 #define SIGK_LAST SIGKSIG /* last kernel signal */
85 #define IS_SIGK(signo) (signo>=SIGK_FIRST && signo<=SIGK_LAST)
87 /* Termination signals for Minix system processes. */
88 #define SIGS_IS_LETHAL(sig) \
89 (sig == SIGILL || sig == SIGBUS || sig == SIGFPE || sig == SIGSEGV \
90 || sig == SIGEMT || sig == SIGABRT)
91 #define SIGS_IS_TERMINATION(sig) (SIGS_IS_LETHAL(sig) \
92 || (sig == SIGKILL || sig == SIGPIPE))
93 #define SIGS_IS_STACKTRACE(sig) (SIGS_IS_LETHAL(sig) && sig != SIGABRT)
97 /* The sighandler_t type is not allowed unless _POSIX_SOURCE is defined. */
98 typedef void _PROTOTYPE( (*__sighandler_t
), (int) );
100 /* Macros used as function pointers. */
101 #define SIG_ERR ((__sighandler_t) -1) /* error return */
102 #define SIG_DFL ((__sighandler_t) 0) /* default signal handling */
103 #define SIG_IGN ((__sighandler_t) 1) /* ignore signal */
104 #define SIG_HOLD ((__sighandler_t) 2) /* block signal */
105 #define SIG_CATCH ((__sighandler_t) 3) /* catch signal */
109 __sighandler_t sa_handler
; /* SIG_DFL, SIG_IGN, or pointer to function */
110 sigset_t sa_mask
; /* signals to be blocked during handler */
111 int sa_flags
; /* special flags */
114 /* Fields for sa_flags. */
115 #define SA_ONSTACK 0x0001 /* deliver signal on alternate stack */
116 #define SA_RESETHAND 0x0002 /* reset signal handler when signal caught */
117 #define SA_NODEFER 0x0004 /* don't block signal while catching it */
118 #define SA_RESTART 0x0008 /* automatic system call restart */
119 #define SA_SIGINFO 0x0010 /* extended signal handling */
120 #define SA_NOCLDWAIT 0x0020 /* don't create zombies */
121 #define SA_NOCLDSTOP 0x0040 /* don't receive SIGCHLD when child stops */
123 /* POSIX requires these values for use with sigprocmask(2). */
124 #define SIG_BLOCK 0 /* for blocking signals */
125 #define SIG_UNBLOCK 1 /* for unblocking signals */
126 #define SIG_SETMASK 2 /* for setting the signal mask */
127 #define SIG_INQUIRE 4 /* for internal use only */
129 /* codes for SIGFPE */
130 #define FPE_INTOVF 1 /* integer divide by zero */
131 #define FPE_INTDIV 2 /* integer overflow */
132 #define FPE_FLTDIV 3 /* floating-point divide by zero */
133 #define FPE_FLTOVF 4 /* floating-point overflow */
134 #define FPE_FLTUND 5 /* floating-point underflow */
135 #define FPE_FLTRES 6 /* floating-point inexact result */
136 #define FPE_FLTINV 7 /* floating-point invalid operation */
137 #define FPE_FLTSUB 8 /* subscript out of range */
139 typedef struct sigaltstack
{
145 #define MINSIGSTKSZ 2048 /* Minimal stack size is 2k */
147 /* Fields for ss_flags */
148 #define SS_ONSTACK 1 /* Process is executing on an alternate stack */
149 #define SS_DISABLE 2 /* Alternate stack is disabled */
152 #endif /* _POSIX_SOURCE */
154 /* POSIX and ANSI function prototypes. */
155 _PROTOTYPE( int raise
, (int _sig
) );
156 _PROTOTYPE( __sighandler_t signal
, (int _sig
, __sighandler_t _func
) );
159 _PROTOTYPE( int kill
, (pid_t _pid
, int _sig
) );
160 _PROTOTYPE( int killpg
, (pid_t _pgrp
, int _sig
) );
161 _PROTOTYPE( int sigaction
,
162 (int _sig
, const struct sigaction
*_act
, struct sigaction
*_oact
) );
163 _PROTOTYPE( int sigpending
, (sigset_t
*_set
) );
164 _PROTOTYPE( int sigprocmask
,
165 (int _how
, const sigset_t
*_set
, sigset_t
*_oset
) );
166 _PROTOTYPE( int sigsuspend
, (const sigset_t
*_sigmask
) );
168 /* For the sigset functions, only use the library version with error
169 * checking from user programs. System programs need to be able to use
170 * nonstanard signals.
173 _PROTOTYPE( int sigaddset
, (sigset_t
*_set
, int _sig
) );
174 _PROTOTYPE( int sigdelset
, (sigset_t
*_set
, int _sig
) );
175 _PROTOTYPE( int sigemptyset
, (sigset_t
*_set
) );
176 _PROTOTYPE( int sigfillset
, (sigset_t
*_set
) );
177 _PROTOTYPE( int sigismember
, (const sigset_t
*_set
, int _sig
) );
179 #define sigaddset(set, sig) ((int) ((*(set) |= (1 << (sig))) && 0))
180 #define sigdelset(set, sig) ((int) ((*(set) &= ~(1 << (sig))) && 0))
181 #define sigemptyset(set) ((int) (*(set) = 0))
182 #define sigfillset(set) ((int) ((*(set) = ~0) && 0))
183 #define sigismember(set, sig) ((*(set) & (1 << (sig))) ? 1 : 0)
188 #endif /* _SIGNAL_H */