I have a strange issue where the code I wrote for a daemonized process to run is not running at all. I'm not getting an error, either.
Here is my code:
println!("Test1");
match daemon(false, false) {
Ok(Fork::Child) => {
let pid = getpid();
let mut pid_file = File::create(PID_FILENAME)
.expect("Unable to create the pid file");
writeln!(pid_file, "{}", pid)
.expect("Unable to write pid to file");
println!("Test2");
let shutdown_result = Command::new("sleep")
.arg("30")
.output();
if let Err(reason) = shutdown_result {
panic!("{reason}");
}
},
Err(reason) => {
panic!("{reason}");
},
_ => unreachable!(),
}
I see Test1 output to stdout but I never see Test2 and the pid file is never created.
My mistake, ofc I wouldn't see Test2, but I still don't see the file being created.
I have a strange issue where the code I wrote for a daemonized process to run is not running at all. I'm not getting an error, either.
Here is my code:
I see
Test1output to stdout but I never seeTest2and the pid file is never created.My mistake, ofc I wouldn't see
Test2, but I still don't see the file being created.