From b3bd92c5f842a9dd96b5b6676525975c0951c896 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sun, 5 Apr 2026 21:44:30 -0600 Subject: [PATCH] fix: replace expect() with match in SIGTERM handler to satisfy clippy --- Cargo.lock | 16 ++++++++-------- src/main.rs | 21 +++++++++++++++------ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d2b34c..1125096 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,7 +97,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -108,7 +108,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -801,7 +801,7 @@ dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -973,7 +973,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -1997,7 +1997,7 @@ dependencies = [ "portable-atomic", "portable-atomic-util", "serde_core", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -2495,7 +2495,7 @@ version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -3234,7 +3234,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b55fb86dfd3a2f5f76ea78310a88f96c4ea21a3031f8d212443d56123fd0521" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -3478,7 +3478,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] diff --git a/src/main.rs b/src/main.rs index f37c97a..a5c0709 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ use clap::{Parser, Subcommand}; use iroh::SecretKey; use tokio::sync::mpsc; use tokio_util::sync::CancellationToken; -use tracing::info; +use tracing::{info, warn}; use crate::gossip::PassphraseKeys; use crate::rate_limit::RateLimiter; @@ -180,12 +180,21 @@ async fn main() -> Result<()> { { let cancel = cancel.clone(); tokio::spawn(async move { - let mut sigterm = tokio::signal::unix::signal( + let sigterm = tokio::signal::unix::signal( tokio::signal::unix::SignalKind::terminate(), - ).expect("failed to register SIGTERM handler"); - tokio::select! { - _ = tokio::signal::ctrl_c() => info!("received SIGINT"), - _ = sigterm.recv() => info!("received SIGTERM"), + ); + match sigterm { + Ok(mut sigterm) => { + tokio::select! { + _ = tokio::signal::ctrl_c() => info!("received SIGINT"), + _ = sigterm.recv() => info!("received SIGTERM"), + } + } + Err(e) => { + warn!("failed to register SIGTERM handler: {e:#}"); + let _ = tokio::signal::ctrl_c().await; + info!("received SIGINT"); + } } cancel.cancel(); });