diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/util.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/util.rs b/src/util.rs index b70f2f16..b8703012 100644 --- a/src/util.rs +++ b/src/util.rs @@ -13,7 +13,7 @@ // limitations under the License. use std::ffi::OsStr; -use std::process::Command; +use std::process::{Command, Stdio}; use std::{cmp, io}; #[cfg(not(windows))] @@ -22,8 +22,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 @@ -91,9 +89,20 @@ where { Command::new(program) .args(args) + .stdin(Stdio::null()) + .stdout(Stdio::null()) + .stderr(Stdio::null()) .before_exec(|| unsafe { - #[allow(deprecated)] - libc::daemon(1, 0); + match ::libc::fork() { + -1 => return Err(io::Error::last_os_error()), + 0 => (), + _ => ::libc::_exit(0), + } + + if ::libc::setsid() == -1 { + return Err(io::Error::last_os_error()); + } + Ok(()) }) .spawn()? |