Skip to main content

Interruptible

Trait Interruptible 

Source
pub trait Interruptible {
    // Required method
    fn pid(&mut self) -> Result<Option<u32>>;

    // Provided methods
    fn interrupt(&mut self) -> Result<()> { ... }
    fn terminate(&mut self) -> Result<()> { ... }
}
Expand description

A trait for sending interrupts/ctrl-c to child processes.

NOTE: By implementing this trait, you are stating that the correct steps have been taken to ensure that the child process can actually be interrupted.

Required Methods§

Source

fn pid(&mut self) -> Result<Option<u32>>

Get the pid of the child process. It returns Ok(Some(u32)) if the process is running and the PID is available. It returns Ok(None) if the process is already known to be completed. An error is returned if one occurs while attempting to get the pid.

Provided Methods§

Source

fn interrupt(&mut self) -> Result<()>

Send an interrupt signal/event to the child process. It returns an error if the process is already known to be completed.

On Windows, this will send a CTRL_C_EVENT event to the process. On Unix, this will send a SIGINT signal to the process.

Source

fn terminate(&mut self) -> Result<()>

Send a terminate signal/event to the child process. It returns an error if the process is already known to be completed.

On Windows, this will send a CTRL_BREAK_EVENT event to the process. On Unix, this will send a SIGTERM signal to the process.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Interruptible for send_ctrlc::InterruptibleChild

Source§

impl Interruptible for send_ctrlc::tokio::InterruptibleChild

Available on crate feature tokio only.