W3cubDocs

/Rust

Trait ChildExt

pub trait ChildExt: Sealed {
    // Required method
    fn send_signal(&self, signal: i32) -> Result<()>;
}
🔬This is a nightly-only experimental API. (unix_send_signal #141975)
Available on Unix only.

Required Methods

Source
fn send_signal(&self, signal: i32) -> Result<()>
🔬This is a nightly-only experimental API. (unix_send_signal #141975)

Sends a signal to a child process.

Errors

This function will return an error if the signal is invalid. The integer values associated with signals are implementation-specific, so it’s encouraged to use a crate that provides posix bindings.

Examples
#![feature(unix_send_signal)]

use std::{io, os::unix::process::ChildExt, process::{Command, Stdio}};

use libc::SIGTERM;

fn main() -> io::Result<()> {
    let child = Command::new("cat").stdin(Stdio::piped()).spawn()?;
    child.send_signal(SIGTERM)?;
    Ok(())
}

Implementors

Source
impl ChildExt for Child

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/os/unix/process/trait.ChildExt.html