From e6ffb3f3e1f62baaf08030a9cb5b06c78725a77a Mon Sep 17 00:00:00 2001 From: EliasSchriefer Date: Sun, 30 Aug 2020 16:37:45 +0200 Subject: [PATCH] Print message when stopping the daemon (SIGTERM) systemd sends SIGTERM when stopping a service. When running in a tty, CTRL + C (SIGINT) currently won't print a shutdown message. --- sfsmcd/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sfsmcd/src/main.rs b/sfsmcd/src/main.rs index 5c3cbbb..a40f589 100644 --- a/sfsmcd/src/main.rs +++ b/sfsmcd/src/main.rs @@ -55,6 +55,7 @@ async fn main() -> Result<(), Box> { // Will (afaik) be stabilized in Rust 1.48 // core::future::pending::<()>().await; - loop {}; - unreachable!(); + tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())?.recv().await; + info!("Got SIGTERM, shutting down"); + Ok(()) } \ No newline at end of file