diff --git a/crates/turborepo-lib/Cargo.toml b/crates/turborepo-lib/Cargo.toml index 27ca9e7aa0cfe..e5a70f25c9310 100644 --- a/crates/turborepo-lib/Cargo.toml +++ b/crates/turborepo-lib/Cargo.toml @@ -59,6 +59,7 @@ json_comments = "0.2.1" jsonc-parser = { version = "0.21.0" } lazy_static = { workspace = true } libc = "0.2.140" +nix = "0.26.2" notify = "5.1" path-clean = "1.0.1" petgraph = { workspace = true } diff --git a/crates/turborepo-lib/src/process/child.rs b/crates/turborepo-lib/src/process/child.rs index 14e01c5ce722d..1656eb06071cd 100644 --- a/crates/turborepo-lib/src/process/child.rs +++ b/crates/turborepo-lib/src/process/child.rs @@ -21,7 +21,6 @@ use std::{ time::Duration, }; -use command_group::AsyncCommandGroup; use itertools::Itertools; pub use tokio::process::Command; use tokio::{ @@ -147,7 +146,6 @@ impl ShutdownStyle { #[derive(Clone, Debug)] pub struct Child { pid: Option, - gid: Option, state: Arc>, exit_channel: watch::Receiver>, stdin: Arc>>, @@ -195,10 +193,19 @@ impl Child { ) }; - let group = command.group().spawn()?; + // Create a process group for the child on unix like systems + #[cfg(unix)] + { + use nix::unistd::setsid; + unsafe { + command.pre_exec(|| { + setsid()?; + Ok(()) + }); + } + } - let gid = group.id(); - let mut child = group.into_inner(); + let mut child = command.spawn()?; let pid = child.id(); let stdin = child.stdin.take(); @@ -278,7 +285,6 @@ impl Child { Ok(Self { pid, - gid, state, exit_channel: exit_rx, stdin: Arc::new(Mutex::new(stdin)),