From 56035f34a23891869d244732a28b95c7675bf7a8 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 9 Dec 2024 11:01:57 -0500 Subject: [PATCH] fix(task): do not always kill child on ctrl+c on windows (#27269) We don't need to forward the kill signal because ctrl+c events are sent to the process group. Closes https://github.com/denoland/deno/issues/27266 --- cli/task_runner.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/task_runner.rs b/cli/task_runner.rs index aabdaf5777..d6589a1832 100644 --- a/cli/task_runner.rs +++ b/cli/task_runner.rs @@ -585,7 +585,13 @@ pub async fn run_future_forwarding_signals( async fn listen_ctrl_c(kill_signal: KillSignal) { while let Ok(()) = tokio::signal::ctrl_c().await { - kill_signal.send(deno_task_shell::SignalKind::SIGINT) + // On windows, ctrl+c is sent to the process group, so the signal would + // have already been sent to the child process. We still want to listen + // for ctrl+c here to keep the process alive when receiving it, but no + // need to forward the signal because it's already been sent. + if !cfg!(windows) { + kill_signal.send(deno_task_shell::SignalKind::SIGINT) + } } }