This commit is contained in:
Federico Terzi 2019-09-15 16:04:27 +02:00
parent 69b026c73c
commit 05ec00698f

View File

@ -290,6 +290,15 @@ fn start_main(config_set: ConfigSet) {
if sid < 0 {
exit(5);
}
// Detach stdout and stderr
let null_path = std::ffi::CString::new("/dev/null").expect("CString unwrap failed");
let fd = libc::open(null_path.as_ptr(), libc::O_RDWR, 0);
if fd != -1 {
libc::dup2(fd, libc::STDIN_FILENO);
libc::dup2(fd, libc::STDOUT_FILENO);
libc::dup2(fd, libc::STDERR_FILENO);
}
}
daemon_main(config_set);