#[non_exhaustive]#[repr(i32)]pub enum SignalType {
KeyboardInterrupt = 103,
IllegalInstruction = 102,
Abort = 100,
MathException = 101,
SegmentationFault = 104,
Termination = 105,
}
signals
only.Expand description
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
KeyboardInterrupt = 103
SIGINT
– keyboard interrupt, usually sent by pressing Ctrl
+C
by the terminal. This signal is typically set to be ignored if the program runs an interactive interface: GUI/TUI, interactive shell (the Python shell, for example) or any other kind of interface which runs in a loop, as opposed to a command-line invocation of the program which reads its standard input or command-line arguments, performs a task and exits. If the interactive interface is running a lengthy operation, a good idea is to temporarily re-enable the signal and abort the lengthy operation if the signal is received, then disable it again.
Default handler: process termination.
IllegalInstruction = 102
SIGILL
– illegal or malformed instruction exception, generated by the CPU whenever such an instruction is executed. This signal normally should not be overriden or masked out, since it likely means that the executable file or the memory of the process has been corrupted and further execution is a risk of invoking negative consequences.
For reasons described above, this signal is considered unsafe – handling it requires using set_unsafe_handler
. Signal hooks for this signal are also required to never return – those must be wrapped into a NoReturnSignalHook
.
Default handler: process termination with a core dump.
Abort = 100
SIGABRT
– abnormal termination requested. This signal is typically invoked by the program itself, using std::process::abort
or the equivalent C function; still, like any other signal, it can be sent from outside the process.
Default handler: process termination with a core dump.
MathException = 101
SIGFPE
– mathematical exception. This signal is generated whenever an undefined mathematical operation is performed – mainly integer division by zero.
Signal hooks for this signal are required to never return – those must be wrapped into a NoReturnSignalHook
.
Default handler: process termination with a core dump.
SegmentationFault = 104
SIGSEGV
– invaid memory access. This signal is issued by the OS whenever the program tries to access an invalid memory location, such as the NULL
pointer or simply an address outside the user-mode address space as established by the OS. The only case when this signal can be received by a Rust program is if memory unsafety occurs due to misuse of unsafe code. As such, it should normally not be masked out or handled, as it likely indicates a critical bug (soundness hole), executable file corruption or process memory corruption.
For reasons described above, this signal is considered unsafe – handling it requires using set_unsafe_handler
. Signal hooks for this signal are also required to never return – those must be wrapped into a NoReturnSignalHook
.
Default handler: process termination with a core dump.
Termination = 105
SIGTERM
– request for termination. This signal can only be sent using the usual signal sending procedures. Unlike KeyboardInterrupt
, this signal is not a request to break out of a lengthy operation, but rather to close the program as a whole. Signal handlers for this signal are expected to perform minimal cleanup and quick state save procedures and then exit.
Default handler: process termination.
Implementations§
Source§impl SignalType
impl SignalType
Sourcepub const fn requires_diverging_hook(self) -> bool
pub const fn requires_diverging_hook(self) -> bool
Returns true
if the value is a signal which requires its custom handler functions to never return, false
otherwise.
Trait Implementations§
Source§impl Clone for SignalType
impl Clone for SignalType
Source§fn clone(&self) -> SignalType
fn clone(&self) -> SignalType
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more