1 |
module include.signal; |
---|
2 |
|
---|
3 |
/* The <signal.h> header defines all the ANSI and POSIX signals. |
---|
4 |
* MINIX supports all the signals required by POSIX. They are defined below. |
---|
5 |
* Some additional signals are also supported. |
---|
6 |
*/ |
---|
7 |
|
---|
8 |
import include.ansi; |
---|
9 |
static if ( _POSIX_SOURCE) { |
---|
10 |
import include.sys.types; |
---|
11 |
} |
---|
12 |
|
---|
13 |
/* Here are types that are closely associated with signal handling. */ |
---|
14 |
typedef int sig_atomic_t; |
---|
15 |
|
---|
16 |
static if ( _POSIX_SOURCE) { |
---|
17 |
typedef ulong sigset_t; |
---|
18 |
} |
---|
19 |
|
---|
20 |
/* Regular signals. */ |
---|
21 |
const SIGHUP = 1; /* hangup */ |
---|
22 |
const SIGINT = 2; /* interrupt (DEL) */ |
---|
23 |
const SIGQUIT = 3; /* quit (ASCII FS) */ |
---|
24 |
const SIGILL = 4; /* illegal instruction */ |
---|
25 |
const SIGTRAP = 5; /* trace trap (not reset when caught) */ |
---|
26 |
const SIGABRT = 6; /* IOT instruction */ |
---|
27 |
const SIGBUS = 7; /* bus error */ |
---|
28 |
const SIGFPE = 8; /* floating point exception */ |
---|
29 |
const SIGKILL = 9; /* kill (cannot be caught or ignored) */ |
---|
30 |
const SIGUSR1 = 10; /* user defined signal # 1 */ |
---|
31 |
const SIGSEGV = 11; /* segmentation violation */ |
---|
32 |
const SIGUSR2 = 12; /* user defined signal # 2 */ |
---|
33 |
const SIGPIPE = 13; /* write on a pipe with no one to read it */ |
---|
34 |
const SIGALRM = 14; /* alarm clock */ |
---|
35 |
const SIGTERM = 15; /* software termination signal from kill */ |
---|
36 |
const SIGEMT = 16; /* EMT instruction */ |
---|
37 |
const SIGCHLD = 17; /* child process terminated or stopped */ |
---|
38 |
const SIGWINCH = 21; /* window size has changed */ |
---|
39 |
|
---|
40 |
/* POSIX requires the following signals to be defined, even if they are |
---|
41 |
* not supported. Here are the definitions, but they are not supported. |
---|
42 |
*/ |
---|
43 |
const SIGCONT = 18; /* continue if stopped */ |
---|
44 |
const SIGSTOP = 19; /* stop signal */ |
---|
45 |
const SIGTSTP = 20; /* interactive stop signal */ |
---|
46 |
const SIGTTIN = 22; /* background process wants to read */ |
---|
47 |
const SIGTTOU = 23; /* background process wants to write */ |
---|
48 |
|
---|
49 |
const _NSIG = 24; /* highest signal number plus one */ |
---|
50 |
|
---|
51 |
static if ( _MINIX) { |
---|
52 |
const SIGIOT = SIGABRT; /* for people who speak PDP-11 */ |
---|
53 |
|
---|
54 |
/* MINIX specific signals. These signals are not used by user proceses, |
---|
55 |
* but meant to inform system processes, like the PM, about system events. |
---|
56 |
*/ |
---|
57 |
const SIGKMESS = 29; /* new kernel message */ |
---|
58 |
const SIGKSIG = 30; /* kernel signal pending */ |
---|
59 |
const SIGKSTOP = 31; /* kernel shutting down */ |
---|
60 |
|
---|
61 |
} |
---|
62 |
|
---|
63 |
/* The sighandler_t type is not allowed unless _POSIX_SOURCE is defined. */ |
---|
64 |
void function (int) __sighandler_t; |
---|
65 |
|
---|
66 |
/* Macros used as function pointers. */ |
---|
67 |
const SIG_ERR = cast (__sighandler_t) -1; /* error return */ |
---|
68 |
const SIG_DFL = cast (__sighandler_t) 0; /* default signal handling */ |
---|
69 |
const SIG_IGN = cast (__sighandler_t) 1; /* ignore signal */ |
---|
70 |
const SIG_HOLD = cast (__sighandler_t) 2; /* block signal */ |
---|
71 |
const SIG_CATCH = cast (__sighandler_t) 3; /* catch signal */ |
---|
72 |
const SIG_MESS = cast (__sighandler_t) 4; /* pass as message (MINIX) */ |
---|
73 |
|
---|
74 |
static if (_POSIX_SOURCE) { |
---|
75 |
struct sigaction { |
---|
76 |
__sighandler_t sa_handler; /* SIG_DFL, SIG_IGN, or pointer to function */ |
---|
77 |
sigset_t sa_mask; /* signals to be blocked during handler */ |
---|
78 |
int sa_flags; /* special flags */ |
---|
79 |
} |
---|
80 |
|
---|
81 |
/* Fields for sa_flags. */ |
---|
82 |
const SA_ONSTACK = 0x0001; /* /* deliver signal on alternate stack */ |
---|
83 |
const SA_RESETHAND = 0x0002; /* /* reset signal handler when signal caught */ |
---|
84 |
const SA_NODEFER = 0x0004; /* /* don't block signal while catching it */ |
---|
85 |
const SA_RESTART = 0x0008; /* /* automatic system call restart */ |
---|
86 |
const SA_SIGINFO = 0x0010; /* /* extended signal handling */ |
---|
87 |
const SA_NOCLDWAIT = 0x0020; /* /* don't create zombies */ |
---|
88 |
const SA_NOCLDSTOP = 0x0040; /* /* don't receive SIGCHLD when child stops */ |
---|
89 |
|
---|
90 |
/* POSIX requires these values for use with sigprocmask(2). */ |
---|
91 |
const SIG_BLOCK = 0; /* /* for blocking signals */ |
---|
92 |
const SIG_UNBLOCK = 1; /* /* for unblocking signals */ |
---|
93 |
const SIG_SETMASK = 2; /* /* for setting the signal mask */ |
---|
94 |
const SIG_INQUIRE = 4; /* /* for internal use only */ |
---|
95 |
} /* _POSIX_SOURCE */ |
---|
96 |
|
---|
97 |
/* POSIX and ANSI function prototypes. */ |
---|
98 |
int function (int _sig) raise; |
---|
99 |
__sighandler_t function (int _sig, __sighandler_t _func) signal; |
---|
100 |
|
---|
101 |
static if ( _POSIX_SOURCE) { |
---|
102 |
int function (pid_t _pid, int _sig) kill; |
---|
103 |
int function (pid_t _pgrp, int _sig) killpg; |
---|
104 |
int function (int _sig, const struct sigaction *_act, struct sigaction *_oact) sigaction; |
---|
105 |
int function (sigset_t *_set, int _sig) sigaddset; |
---|
106 |
int function (sigset_t *_set, int _sig) sigdelset; |
---|
107 |
int function (sigset_t *_set) sigemptyset; |
---|
108 |
int function (sigset_t *_set) sigfillset; |
---|
109 |
int function (const sigset_t *_set, int _sig) sigismember; |
---|
110 |
int function (sigset_t *_set) sigpending; |
---|
111 |
int function (int _how, const sigset_t *_set, sigset_t *_oset) sigprocmask; |
---|
112 |
int function (const sigset_t *_sigmask) sigsuspend; |
---|
113 |
} |
---|