Enum SignalType

Source
#[non_exhaustive]
#[repr(i32)]
pub enum SignalType { KeyboardInterrupt = 103, IllegalInstruction = 102, Abort = 100, MathException = 101, SegmentationFault = 104, Termination = 105, }
Available on Windows and crate feature signals only.
Expand description

All standard signal types as defined in the C standard.

The values can be safely and quickly converted to i32/u32. The reverse process involves safety checks, making sure that unknown signal values are never stored.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

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.

Source

pub const fn is_unsafe(self) -> bool

Returns true if the value is an unsafe signal which requires unsafe code when setting a handling method, false otherwise.

Trait Implementations§

Source§

impl Clone for SignalType

Source§

fn clone(&self) -> SignalType

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SignalType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<SignalType> for i32

Source§

fn from(op: SignalType) -> Self

Converts to this type from the input type.
Source§

impl From<SignalType> for u32

Source§

fn from(op: SignalType) -> Self

Converts to this type from the input type.
Source§

impl Hash for SignalType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for SignalType

Source§

fn eq(&self, other: &SignalType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<i32> for SignalType

Source§

type Error = UnknownSignalError

The type returned in the event of a conversion error.
Source§

fn try_from(value: i32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u32> for SignalType

Source§

type Error = UnknownSignalError

The type returned in the event of a conversion error.
Source§

fn try_from(value: u32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for SignalType

Source§

impl Eq for SignalType

Source§

impl StructuralPartialEq for SignalType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> To for T
where T: ?Sized,

Source§

fn to<T>(self) -> T
where Self: Into<T>,

Converts to T by calling Into<T>::into.
Source§

fn try_to<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.