From 835f97d3c251b5e6970c4d18a6b8e8231ff3a4e1 Mon Sep 17 00:00:00 2001 From: Houmgaor Date: Wed, 18 Mar 2026 21:36:24 +0100 Subject: [PATCH] fix(shutdown): force-stop on second SIGINT during countdown A second Ctrl+C/SIGINT while the 10-second shutdown countdown is running now exits immediately instead of being silently dropped. The signal channel is buffered to 2 so the second signal is captured, and the countdown select exits via os.Exit(1) on receipt. --- CHANGELOG.md | 1 + main.go | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 380c74e30..98ecb7502 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- A second SIGINT/Ctrl+C during the shutdown countdown now force-stops the server immediately - Fixed `ecdMagic` constant byte order causing encryption failures on some platforms ([#174](https://github.com/Mezeporta/Erupe/issues/174)) - Fixed guild nil panics: variable shadowing causing nil panic in scout list ([#171](https://github.com/Mezeporta/Erupe/issues/171)) - Fixed guild nil panics: added nil guards in cancel and answer scout handlers ([#171](https://github.com/Mezeporta/Erupe/issues/171)) diff --git a/main.go b/main.go index c96d814e7..0aee2a227 100644 --- a/main.go +++ b/main.go @@ -388,9 +388,9 @@ func main() { logger.Info("Finished starting Erupe") // Wait for exit or interrupt with ctrl+C. - c := make(chan os.Signal, 1) - signal.Notify(c, os.Interrupt, syscall.SIGTERM) - <-c + sig := make(chan os.Signal, 2) + signal.Notify(sig, os.Interrupt, syscall.SIGTERM) + <-sig if !config.DisableSoftCrash { for i := 0; i < 10; i++ { @@ -399,7 +399,12 @@ func main() { c.BroadcastChatMessage(message) } logger.Info(message) - time.Sleep(time.Second) + select { + case <-sig: + logger.Info("Second signal received, forcing shutdown") + os.Exit(1) + case <-time.After(time.Second): + } } }