From 1b47eee4c0b401eec9f2696181c3439f27c5cbfa Mon Sep 17 00:00:00 2001 From: Alice Hau <110418948+ahau-square@users.noreply.github.com> Date: Thu, 8 May 2025 14:28:12 -0400 Subject: [PATCH] fix: move process group termination instead unix code block (#2481) Co-authored-by: Alice Hau --- crates/goose-cli/src/commands/mcp.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/goose-cli/src/commands/mcp.rs b/crates/goose-cli/src/commands/mcp.rs index 168dab91..8fbd399f 100644 --- a/crates/goose-cli/src/commands/mcp.rs +++ b/crates/goose-cli/src/commands/mcp.rs @@ -59,13 +59,14 @@ pub async fn run_server(name: &str) -> Result<()> { _ = shutdown.notified() => { // On Unix systems, kill the entire process group #[cfg(unix)] - fn terminate_process_group() { - let pgid = getpgrp(); - kill(Pid::from_raw(-pgid.as_raw()), Signal::SIGTERM) - .expect("Failed to send SIGTERM to process group"); + { + fn terminate_process_group() { + let pgid = getpgrp(); + kill(Pid::from_raw(-pgid.as_raw()), Signal::SIGTERM) + .expect("Failed to send SIGTERM to process group"); + } + terminate_process_group(); } - terminate_process_group(); - Ok(()) } }