From 1750b0b7d4e922a25624a5e48409af5497135fe7 Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Thu, 11 Jan 2024 14:29:50 -0800 Subject: [PATCH 1/2] chore: remove gid field from child --- crates/turborepo-lib/src/process/child.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/crates/turborepo-lib/src/process/child.rs b/crates/turborepo-lib/src/process/child.rs index 14e01c5ce722d..a14794eb0feaf 100644 --- a/crates/turborepo-lib/src/process/child.rs +++ b/crates/turborepo-lib/src/process/child.rs @@ -147,7 +147,6 @@ impl ShutdownStyle { #[derive(Clone, Debug)] pub struct Child { pid: Option, - gid: Option, state: Arc>, exit_channel: watch::Receiver>, stdin: Arc>>, @@ -197,7 +196,6 @@ impl Child { let group = command.group().spawn()?; - let gid = group.id(); let mut child = group.into_inner(); let pid = child.id(); @@ -278,7 +276,6 @@ impl Child { Ok(Self { pid, - gid, state, exit_channel: exit_rx, stdin: Arc::new(Mutex::new(stdin)), From fb7ff5941f054105d835dd330fdf25db5170fe93 Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Thu, 11 Jan 2024 15:35:04 -0800 Subject: [PATCH 2/2] chore: remove usage of command-groups in process manager --- crates/turborepo-lib/Cargo.toml | 1 + crates/turborepo-lib/src/process/child.rs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) 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 a14794eb0feaf..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::{ @@ -194,9 +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 mut child = group.into_inner(); + let mut child = command.spawn()?; let pid = child.id(); let stdin = child.stdin.take();