Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat: Handle concurrent dev-detach builds and prevent zombie processes
Maximilian Roosebf820277c53
diff --git a/src/commands/process.rs b/src/commands/process.rsindex 6eac10bcb..f916aff7d 100644--- a/src/commands/process.rs+++ b/src/commands/process.rs@@ -70,9 +70,10 @@ fn spawn_detached_unix(// - nohup makes the process immune to SIGHUP (continues after parent exits)// - sh -c allows complex shell commands with pipes, redirects, etc.// - & backgrounds the process immediately- // - Parent process doesn't wait, allowing immediate return+ // - We wait for the outer shell to exit (happens immediately after backgrounding)+ // - This prevents zombie process accumulation under high concurrency// - Output redirected to log file for debugging- Command::new("sh")+ let mut child = Command::new("sh").arg("-c").arg(format!("nohup sh -c {} &",@@ -87,6 +88,11 @@ fn spawn_detached_unix(.spawn().git_context("Failed to spawn detached process")?;+ // Wait for the outer shell to exit (immediate, doesn't block on background command)+ child+ .wait()+ .git_context("Failed to wait for detachment shell")?;+Ok(())}