relibc/header/signal/constants.rs
1// These constants have the same values on Redox and Linux.
2
3// Default actions are:
4// - T (Abnormal termination of the process)
5// - A (Abnormal termination of the process with additional actions)
6// - I (Ignore the signal)
7// - S (Stop the process)
8// - C (Continue the process, if it is stopped; otherwise, ignore the signal)
9
10/// Hangup.
11/// Default action: T
12pub const SIGHUP: usize = 1;
13/// Terminal interrupt signal.
14/// Default action: T
15pub const SIGINT: usize = 2;
16/// Terminal quit signal.
17/// Default action: A
18pub const SIGQUIT: usize = 3;
19/// Illegal instruction.
20/// Default action: A
21pub const SIGILL: usize = 4;
22/// Trace/Breakpoint trap.
23/// Default action: A
24pub const SIGTRAP: usize = 5;
25/// Process abort signal.
26/// Default action: A
27pub const SIGABRT: usize = 6;
28/// Access to an undefined portion of a memory object.
29/// Default action: A
30pub const SIGBUS: usize = 7;
31/// Erroneous arithmetic operation.
32/// Default action: A
33pub const SIGFPE: usize = 8;
34/// Kill (cannot be caught or ignored).
35/// Default action: T
36pub const SIGKILL: usize = 9;
37/// User-defined signal 1.
38/// Default action: T
39pub const SIGUSR1: usize = 10;
40/// Invalid memory reference.
41/// Default action: A
42pub const SIGSEGV: usize = 11;
43/// User-defined signal 2.
44/// Default action: T
45pub const SIGUSR2: usize = 12;
46/// Write on a pipe with no one to read it.
47/// Default action: T
48pub const SIGPIPE: usize = 13;
49/// Alarm clock.
50/// Default action: T
51pub const SIGALRM: usize = 14;
52/// Termination signal.
53/// Default action: T
54pub const SIGTERM: usize = 15;
55/// Non-POSIX, see <https://www.man7.org/linux/man-pages/man7/signal.7.html>.
56///
57/// Stack fault on coprocessor (unused).
58pub const SIGSTKFLT: usize = 16;
59/// Child process terminated, stopped or continued.
60/// Default action: I
61pub const SIGCHLD: usize = 17;
62/// Continue executing, if stopped.
63/// Default action: C
64pub const SIGCONT: usize = 18;
65/// Stop executing (cannot be caught or ignored).
66/// Default action: S
67pub const SIGSTOP: usize = 19;
68/// Terminal stop signal.
69/// Default action: S
70pub const SIGTSTP: usize = 20;
71/// Background process attempting read.
72/// Default action: S
73pub const SIGTTIN: usize = 21;
74/// Background process attempting write.
75/// Default action: S
76pub const SIGTTOU: usize = 22;
77/// High bandwidth data is available at a socket.
78/// Default action: I
79pub const SIGURG: usize = 23;
80/// CPU time limit exceeded.
81/// Default action: A
82pub const SIGXCPU: usize = 24;
83/// File size limit exceeded.
84/// Default action: A
85pub const SIGXFSZ: usize = 25;
86/// Virtual timer expired.
87/// Default action: T
88pub const SIGVTALRM: usize = 26;
89// TODO mark #[deprecated]?
90/// Obsolete in issue 7, removed in issue 8.
91///
92/// Profiling timer expired.
93/// Default action: T
94pub const SIGPROF: usize = 27;
95/// Terminal window size changed.
96/// Default action: I
97pub const SIGWINCH: usize = 28;
98/// Non-POSIX, see <https://www.man7.org/linux/man-pages/man7/signal.7.html>.
99///
100/// I/O now possible (4.2BSD).
101pub const SIGIO: usize = 29;
102/// Non-POSIX, see <https://www.man7.org/linux/man-pages/man7/signal.7.html>.
103///
104/// Power failure (System V).
105pub const SIGPWR: usize = 30;
106/// Bad system call.
107/// Default action: A
108pub const SIGSYS: usize = 31;
109// TODO add `NSIG_MAX` to limits.h and `_SC_NSIG` to unistd.h sysconf
110/// Non-POSIX.
111///
112/// Intended to define the maximum number of signals supported by this
113/// implemenatation.
114///
115/// POSIX added `NSIG_MAX` as a portable replacement based on the size of the
116/// `sigset_t` type.
117pub const NSIG: usize = 32;
118
119/// Lower bound (inclusive) of the range of signal numbers reserved for
120/// application use and for realtime signals.
121pub const SIGRTMIN: usize = 35; // TODO: decrease to 34
122/// Upper bound (inclusive) of the range of signal numbers reserved for
123/// application use and for realtime signals.
124pub const SIGRTMAX: usize = 64;
125
126/// Causes implementations not to create zombie processes or status information
127/// on child termination. See `sigaction()`.
128pub const SA_NOCLDWAIT: usize = 2;
129
130/// Process is executing on an alternate signal stack.
131pub const SS_ONSTACK: usize = 1;
132/// Alternate signal stack is disabled.
133pub const SS_DISABLE: usize = 2;
134
135// Redox note: should include both SigStack size, and some extra room for the libc handler
136// Linux note: Those two should be updated from kernel headers
137/// Minimum stack size for a signal handler.
138pub const MINSIGSTKSZ: usize = 2048;
139/// Default size in bytes for the alternate signal stack.
140pub const SIGSTKSZ: usize = 8096;
141
142/// Signal sent by `sigqueue()`.
143pub const SI_QUEUE: i32 = -1;
144/// Signal sent by `kill()`.
145pub const SI_USER: i32 = 0;
146/// Signal generated by expiration of a timer set by `timer_settime()`.
147pub const SI_TIMER: i32 = 1;
148/// Signal generated by completion of an asynchronous I/O request.
149pub const SI_ASYNCIO: i32 = 2;
150/// Signal generated by arrival of a message on an empty message queue.
151pub const SI_MESGQ: i32 = 3;
152
153// si_code values (signal-specific)
154/// Illegal opcode.
155pub const ILL_ILLOPC: i32 = 1;
156/// Illegal operand.
157pub const ILL_ILLOPN: i32 = 2;
158/// Illegal addressing mode.
159pub const ILL_ILLADR: i32 = 3;
160/// Illegal trap.
161pub const ILL_ILLTRP: i32 = 4;
162/// Privileged opcode.
163pub const ILL_PRVOPC: i32 = 5;
164/// Privileged register.
165pub const ILL_PRVREG: i32 = 6;
166/// Coprocessor error.
167pub const ILL_COPROC: i32 = 7;
168/// Internal stack error.
169pub const ILL_BADSTK: i32 = 8;
170
171/// Integer divide by zero.
172pub const FPE_INTDIV: i32 = 1;
173/// Integer overflow.
174pub const FPE_INTOVF: i32 = 2;
175/// Floating-point divide by zero.
176pub const FPE_FLTDIV: i32 = 3;
177/// Floating-point overflow.
178pub const FPE_FLTOVF: i32 = 4;
179/// Floating-point underflow.
180pub const FPE_FLTUND: i32 = 5;
181/// Floating-point inexact result.
182pub const FPE_FLTRES: i32 = 6;
183/// Invalid floating-point operation.
184pub const FPE_FLTINV: i32 = 7;
185/// Subscript out of range.
186pub const FPE_FLTSUB: i32 = 8;
187
188/// Address not mapped to object.
189pub const SEGV_MAPERR: i32 = 1;
190/// Invalid permissions for mapped object.
191pub const SEGV_ACCERR: i32 = 2;
192
193/// Invalid address alignment.
194pub const BUS_ADRALN: i32 = 1;
195/// Nonexistent physical address.
196pub const BUS_ADRERR: i32 = 2;
197/// Object-specific hardware error.
198pub const BUS_OBJERR: i32 = 3;
199
200/// Process breakpoint.
201pub const TRAP_BRKPT: i32 = 1;
202/// Process trace trap.
203pub const TRAP_TRACE: i32 = 2;
204
205/// Child has exited.
206pub const CLD_EXITED: i32 = 1;
207/// Child has terminated abnormally with no additional actions.
208pub const CLD_KILLED: i32 = 2;
209/// Child has terminated abnormally and additional actions may have been taken.
210pub const CLD_DUMPED: i32 = 3;
211/// Traced child has trapped.
212pub const CLD_TRAPPED: i32 = 4;
213/// Child has stopped.
214pub const CLD_STOPPED: i32 = 5;
215/// Stopped child has continued.
216pub const CLD_CONTINUED: i32 = 6;