From 035aa4b2561ed1c0593693a3e018152b189f9505 Mon Sep 17 00:00:00 2001 From: Mollusk Date: Thu, 28 May 2026 15:40:05 -0400 Subject: [PATCH] fix(signal): warn instead of silently dropping a failed ctrl-c handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit install_ctrl_c() used `if ctrl_c().await.is_ok()`, so if the handler failed to install, ctrl-c silently stopped working with no diagnostic. Match on the Result and log a warning (then bail the task — the second arm would only fail the same way). Co-Authored-By: Claude Opus 4.8 --- src/common/signal.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/common/signal.rs b/src/common/signal.rs index 779cde4..9d8ec2a 100644 --- a/src/common/signal.rs +++ b/src/common/signal.rs @@ -7,10 +7,17 @@ pub fn install_ctrl_c() -> CancellationToken { let token = CancellationToken::new(); let trigger = token.clone(); tokio::spawn(async move { - if tokio::signal::ctrl_c().await.is_ok() { - tracing::info!("ctrl-c received, shutting down"); - trigger.cancel(); + if let Err(e) = tokio::signal::ctrl_c().await { + // Installing the handler failed — ctrl-c won't trigger a graceful + // shutdown. Say so instead of failing silently; the user can still + // kill the process, and the second-ctrl-c arm below would only fail + // the same way, so bail out of the task. + tracing::warn!("could not install ctrl-c handler: {e}; ctrl-c won't shut down cleanly"); + return; } + tracing::info!("ctrl-c received, shutting down"); + trigger.cancel(); + if tokio::signal::ctrl_c().await.is_ok() { tracing::warn!("second ctrl-c — exiting now"); std::process::exit(130);