diff --git a/src/util.rs b/src/util.rs index b7a05041..4532d2e4 100644 --- a/src/util.rs +++ b/src/util.rs @@ -15,6 +15,7 @@ use std::{cmp, io}; use std::ffi::OsStr; use std::process::Command; +use std::process::Stdio; #[cfg(not(windows))] use std::os::unix::process::CommandExt; @@ -22,8 +23,6 @@ use std::os::unix::process::CommandExt; #[cfg(windows)] use std::os::windows::process::CommandExt; #[cfg(windows)] -use std::process::Stdio; -#[cfg(windows)] use winapi::um::winbase::{CREATE_NEW_PROCESS_GROUP, CREATE_NO_WINDOW}; /// Threading utilities @@ -94,8 +93,13 @@ pub fn start_daemon(program: &str, args: I) -> io::Result<()> { Command::new(program) .args(args) + .stdin(Stdio::null()) + .stdout(Stdio::null()) + .stderr(Stdio::null()) .before_exec(|| unsafe { - ::libc::daemon(1, 0); + if ::libc::fork() != 0 { + std::process::exit(0); + } Ok(()) }) .spawn()?