#![allow(clippy::expect_used)]
#![allow(clippy::match_wild_err_arm)]
use std::process::Command;
use fork::{Fork, daemon};
fn main() {
match daemon(false, true) {
Ok(Fork::Child) => {
println!("daemon pid: {}", std::process::id());
Command::new("sleep")
.arg("300")
.output()
.expect("failed to execute process");
}
Ok(Fork::Parent(_)) => unreachable!("daemon exits parent processes"),
Err(err) => eprintln!("daemon failed: {err}"),
}
}