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.
This commit is contained in:
Houmgaor
2026-03-18 21:36:24 +01:00
parent 8785ebc21a
commit 835f97d3c2
2 changed files with 10 additions and 4 deletions

13
main.go
View File

@@ -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):
}
}
}