Struct Signal

Source
pub struct Signal(/* private fields */);
Expand description

A Unix-like signal.

Represents a signal that can be sent to or received by processes on Unix-like systems.

Implementations§

Source§

impl Signal

Source

pub const NULL: Self

Null signal.

Corresponds to signal number 0.

Can be used to check if a process exists without sending an actual signal.

Source

pub const HANGUP: Self

Hangup (SIGHUP).

Corresponds to signal number 1.

Sent to a process when its controlling terminal is closed or when a parent process exits, often used by daemons to re-read configuration files.

Source

pub const INTERRUPT: Self

Interrupt (SIGINT).

Corresponds to signal number 2.

Sent by the terminal to the foreground process group to request its termination, often initiated by the user pressing Ctrl+C.

Source

pub const QUIT: Self

Quit (SIGQUIT).

Corresponds to signal number 3.

Sent by the terminal to the foreground process group (often by pressing Ctrl+\). Typically causes a core dump and process termination.

Source

pub const ILLEGAL_INSTRUCTION: Self

Illegal instruction (SIGILL).

Corresponds to signal number 4.

Indicates an attempt to execute an invalid or malformed instruction.

Source

pub const TRAP: Self

Trace trap (SIGTRAP).

Corresponds to signal number 5.

Used by debuggers to implement breakpoints.

Source

pub const ABORT: Self

Abort (SIGABRT).

Corresponds to signal number 6.

Sent by the abort() function (or _exit() in some cases) to indicate an abnormal termination, typically due to a detected internal inconsistency. Often causes a core dump.

Source

pub const BUS_ERROR: Self

Bus error (SIGBUS).

Corresponds to signal number 7.

Indicates a memory access error, often due to misaligned access or non-existent physical address.

Source

pub const FLOATING_POINT_EXCEPTION: Self

Floating-point exception (SIGFPE).

Corresponds to signal number 8.

Indicates an erroneous arithmetic operation (e.g., division by zero, overflow).

Source

pub const KILL: Self

Kill (SIGKILL).

Corresponds to signal number 9.

Unconditionally terminates a process. This signal cannot be caught, blocked, or ignored, making it the most forceful way to kill a process.

Source

pub const USER1: Self

User-defined signal 1 (SIGUSR1).

Corresponds to signal number 10 (often).

A custom signal for application-specific use. Its exact number can vary by system.

Source

pub const SEGMENTATION_VIOLATION: Self

Segmentation violation (SIGSEGV).

Corresponds to signal number 11.

Indicates an invalid memory access (e.g., trying to write to read-only memory, or access outside allocated bounds). Typically causes a core dump.

Source

pub const USER2: Self

User-defined signal 2 (SIGUSR2).

Corresponds to signal number 12 (often).

Another custom signal for application-specific use. Its exact number can vary by system.

Source

pub const BROKEN_PIPE: Self

Broken pipe (SIGPIPE).

Corresponds to signal number 13.

Sent when a process attempts to write to a pipe, socket, or FIFO whose reading end has been closed.

Source

pub const ALARM: Self

Alarm clock (SIGALRM).

Corresponds to signal number 14.

Generated by the alarm() system call for timer expiration.

Source

pub const TERMINATION: Self

Termination (SIGTERM).

Corresponds to signal number 15.

A generic request to terminate a process. Unlike SIGKILL, this signal can be caught and handled by the process to perform cleanup before exiting gracefully.

Source

pub const STACK_FAULT: Self

Stack fault (SIGSTKFLT).

Corresponds to signal number 16.

(Linux specific) Indicates a stack fault on a coprocessor. Less common.

Source

pub const CHILD: Self

Child stopped or terminated (SIGCHLD).

Corresponds to signal number 17.

Sent to a parent process when one of its child processes stops or terminates.

Source

pub const CONTINUE: Self

Continue (SIGCONT).

Corresponds to signal number 18.

If the process is stopped, it is resumed. If it is already running, it continues.

Source

pub const STOP: Self

Stop (SIGSTOP).

Corresponds to signal number 19.

Stops a process. Unlike SIGTSTP, this signal cannot be caught, blocked, or ignored, making it a forceful way to pause execution.

Source

pub const TTY_STOP: Self

Tty stop (SIGTSTP).

Corresponds to signal number 20.

Sent by the terminal to the foreground process group when the user presses Ctrl+Z.

Can be caught and handled to allow the process to clean up or save state before stopping.

Source

pub const TTY_IN: Self

Background read from tty (SIGTTIN).

Corresponds to signal number 21.

Sent to a process in the background when it attempts to read from its controlling terminal.

Source

pub const TTY_OUT: Self

Background write to tty (SIGTTOU).

Corresponds to signal number 22.

Sent to a process in the background when it attempts to write to its controlling terminal.

Source

pub const URGENT_IO: Self

Urgent condition on socket (SIGURG).

Corresponds to signal number 23.

Indicates urgent data is available on a socket.

Source

pub const CPU_LIMIT: Self

CPU time limit exceeded (SIGXCPU).

Corresponds to signal number 24.

Sent when a process exceeds its CPU time limit.

Source

pub const FILE_SIZE_LIMIT: Self

File size limit exceeded (SIGXFSZ).

Corresponds to signal number 25.

Sent when a process attempts to create a file larger than its imposed limit.

Source

pub const VIRTUAL_ALARM: Self

Virtual alarm clock (SIGVTALRM).

Corresponds to signal number 26.

Generated by a virtual alarm clock, often used for profiling.

Source

pub const PROFILING_TIMER: Self

Profiling timer expired (SIGPROF).

Corresponds to signal number 27.

Generated by a profiling timer, typically used for profiling applications.

Source

pub const WINDOW_CHANGED: Self

Window changed (SIGWINCH).

Corresponds to signal number 28.

Sent to the foreground process group when the terminal window size has changed.

Source

pub const IO_POSSIBLE: Self

I/O is possible (SIGIO).

Corresponds to signal number 29.

Indicates that asynchronous I/O is possible on a file descriptor.

Source

pub const POWER_FAILURE: Self

Power failure restart (SIGPWR).

Corresponds to signal number 30.

(Linux specific) Indicates a power failure.

Source

pub const BAD_SYSTEM_CALL: Self

Bad system call (SIGSYS).

Corresponds to signal number 31.

Indicates an invalid system call.

Source

pub const fn from_raw(signal: u8) -> Self

Creates a new UnixTerminationSignal from the underlying u8 signal number.

Source

pub const fn to_raw(&self) -> u8

Returns the underlying u8 signal number.

Trait Implementations§

Source§

impl Clone for Signal

Source§

fn clone(&self) -> Signal

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Signal

Source§

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

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

impl Display for Signal

Source§

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

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

impl From<u8> for Signal

Source§

fn from(signal: u8) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Signal

Source§

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

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

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 Copy for Signal

Source§

impl Eq for Signal

Source§

impl StructuralPartialEq for Signal

Auto Trait Implementations§

§

impl Freeze for Signal

§

impl RefUnwindSafe for Signal

§

impl Send for Signal

§

impl Sync for Signal

§

impl Unpin for Signal

§

impl UnwindSafe for Signal

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.