logo
pub enum SubSignal {
    Hangup,
    ForceStop,
    Interrupt,
    Quit,
    Terminate,
    User1,
    User2,
    Custom(i32),
}
Expand description

A notification sent to a subprocess.

On Windows, only some signals are supported, as described. Others will be ignored.

On Unix, there are several “first-class” signals which have their own variants, and a generic Custom variant which can be used to send arbitrary signals.

Variants

Hangup

Indicate that the terminal is disconnected.

On Unix, this is SIGHUP. On Windows, this is ignored for now but may be supported in the future (see #219).

Despite its nominal purpose, on Unix this signal is often used to reload configuration files.

ForceStop

Indicate to the kernel that the process should stop.

On Unix, this is SIGKILL. On Windows, this is TerminateProcess.

This signal is not handled by the process, but directly by the kernel, and thus cannot be intercepted. Subprocesses may exit in inconsistent states.

Interrupt

Indicate that the process should stop.

On Unix, this is SIGINT. On Windows, this is ignored for now but may be supported in the future (see #219).

This signal generally indicates an action taken by the user, so it may be handled differently than a termination.

Quit

Indicate that the process is to stop, the kernel will then dump its core.

On Unix, this is SIGQUIT. On Windows, it is ignored.

This is rarely used.

Terminate

Indicate that the process should stop.

On Unix, this is SIGTERM. On Windows, this is ignored for now but may be supported in the future (see #219).

On Unix, this signal generally indicates an action taken by the system, so it may be handled differently than an interruption.

User1

Indicate an application-defined behaviour should happen.

On Unix, this is SIGUSR1. On Windows, it is ignored.

This signal is generally used to start debugging.

User2

Indicate an application-defined behaviour should happen.

On Unix, this is SIGUSR2. On Windows, it is ignored.

This signal is generally used to reload configuration.

Custom(i32)

Indicate using a custom signal.

Internally, this is converted to a nix::Signal but for portability this variant is a raw i32.

Invalid signals on the current platform will be ignored. Does nothing on Windows.

Examples

use watchexec::signal::process::SubSignal;
use nix::sys::signal::Signal;
assert_eq!(SubSignal::Custom(6), SubSignal::from(Signal::SIGABRT as i32));

On Unix the from_nix method should be preferred if converting from Nix’s Signal type:

use watchexec::signal::process::SubSignal;
use nix::sys::signal::Signal;
assert_eq!(SubSignal::Custom(6), SubSignal::from_nix(Signal::SIGABRT));

Implementations

Converts to a [nix::Signal][command_group::Signal] if possible.

This will return None if the signal is not supported on the current platform (only for Custom, as the first-class ones are always supported).

Converts from a [nix::Signal][command_group::Signal].

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Converts from a raw signal number.

This uses hardcoded numbers for the first-class signals.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more