How do I send a signal to a `Child` subprocess?

The nix library does a good job of providing idiomatic rust wrappers around low-level UNIX operations, including sending and handling signals. In this case, you would create a nix::Pid from child_process.id(), then pass it to kill like so:

use nix::unistd::Pid;
use nix::sys::signal::{self, Signal};

// Spawn child process.
let mut child = std::process::Command::new();
/* build rest of command */
child.spawn().unwrap();

// Send SIGTERM to child process.
signal::kill(Pid::from_raw(child.id()), Signal::SIGTERM).unwrap();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)