use std::os::unix::process::ExitStatusExt;
use tokio::process::{Child, Command};
use crate::daemon::paths::DaemonPaths;
pub(crate) struct StopTarget(Child);
impl StopTarget {
pub(crate) fn listen(_paths: &DaemonPaths) -> Self {
Self(
Command::new("sleep")
.arg("600")
.kill_on_drop(true)
.spawn()
.expect("sleep starts"),
)
}
pub(crate) fn pid(&self) -> u32 {
self.0.id().expect("the process is running")
}
pub(crate) async fn asked(&mut self) {
let ended = self.0.wait().await.expect("the process is awaited");
assert_eq!(ended.signal(), Some(libc::SIGTERM));
}
}