From 309919ad24e5b38abc500f4db2c0d5751fa9d8fb Mon Sep 17 00:00:00 2001 From: Sephyi Date: Sun, 19 Apr 2026 18:42:05 +0200 Subject: [PATCH] fix(app): log Ctrl+C handler install failures instead of silently discarding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Ctrl+C handler task used `signal::ctrl_c().await.ok();` which silently swallowed platform-specific signal-registration errors. On Unix, `signal::ctrl_c()` can fail when installing the SIGINT handler (for example, if another library already captured SIGINT non-reentrantly, or if the runtime lacks signal capabilities). Discarding that error meant we would proceed to cancel the token on an unrelated future-ready state, or worse, never react to Ctrl+C at all without any diagnostic. Replace `.ok()` with an explicit match that logs the install failure at `warn!` level (including the error via `%e`) and returns from the task without firing `cancel.cancel()`. This makes the failure mode observable in debug logs and avoids a spurious cancellation when signal registration fails outright. Normal test runs never exercise this branch — signal registration succeeds on all supported platforms during testing. Closes audit entry F-025 from #3. --- src/app.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index cae18dc..1b8d8f2 100644 --- a/src/app.rs +++ b/src/app.rs @@ -86,7 +86,10 @@ impl App { // Setup Ctrl+C handler with CancellationToken let cancel = self.cancel_token.clone(); tokio::spawn(async move { - signal::ctrl_c().await.ok(); + if let Err(e) = signal::ctrl_c().await { + warn!(error = %e, "failed to install Ctrl+C handler"); + return; + } cancel.cancel(); });