diff --git a/core/src/external/shell.rs b/core/src/external/shell.rs index 5011b707..fa4cc948 100644 --- a/core/src/external/shell.rs +++ b/core/src/external/shell.rs @@ -30,7 +30,7 @@ impl ShellOpt { pub fn shell(opt: ShellOpt) -> Result { #[cfg(unix)] - return Ok( + return Ok(unsafe { Command::new("sh") .arg("-c") .stdin(opt.stdio()) @@ -40,8 +40,14 @@ pub fn shell(opt: ShellOpt) -> Result { .arg("") // $0 is the command name .args(opt.args) .kill_on_drop(!opt.orphan) - .spawn()?, - ); + .pre_exec(move || { + if opt.orphan && libc::setpgid(0i32, 0i32) < 0 { + libc::perror(std::ptr::null()); + } + Ok(()) + }) + .spawn()? + }); #[cfg(windows)] {