From 7f112a761cb7d3d47188b7ffcd638ad343cffecb Mon Sep 17 00:00:00 2001 From: Catherine Date: Thu, 11 Dec 2025 10:09:29 +0000 Subject: [PATCH] Simplify signal handling code. This does not require `//go:build`. --- src/{signal_posix.go => signal.go} | 6 ++++-- src/signal_other.go | 13 ------------- 2 files changed, 4 insertions(+), 15 deletions(-) rename src/{signal_posix.go => signal.go} (54%) delete mode 100644 src/signal_other.go diff --git a/src/signal_posix.go b/src/signal.go similarity index 54% rename from src/signal_posix.go rename to src/signal.go index b38531a..8962536 100644 --- a/src/signal_posix.go +++ b/src/signal.go @@ -1,4 +1,6 @@ -//go:build unix +// See https://pkg.go.dev/os/signal#hdr-Windows for a description of what this module +// will do on Windows (tl;dr nothing calls the reload handler, the interrupt handler works +// more or less how you'd expect). package git_pages @@ -21,7 +23,7 @@ func OnReload(handler func()) { func WaitForInterrupt() { sigint := make(chan os.Signal, 1) - signal.Notify(sigint, syscall.SIGINT) + signal.Notify(sigint, syscall.SIGINT, syscall.SIGTERM) <-sigint signal.Stop(sigint) } diff --git a/src/signal_other.go b/src/signal_other.go deleted file mode 100644 index ac617f4..0000000 --- a/src/signal_other.go +++ /dev/null @@ -1,13 +0,0 @@ -//go:build !unix - -package git_pages - -func OnReload(handler func()) { - // not implemented -} - -func WaitForInterrupt() { - for { - // Ctrl+C not supported - } -}