···1+// See https://pkg.go.dev/os/signal#hdr-Windows for a description of what this module
2+// will do on Windows (tl;dr nothing calls the reload handler, the interrupt handler works
3+// more or less how you'd expect).
4+5+package git_pages
6+7+import (
8+ "os"
9+ "os/signal"
10+ "syscall"
11+)
12+13+func OnReload(handler func()) {
14+ sighup := make(chan os.Signal, 1)
15+ signal.Notify(sighup, syscall.SIGHUP)
16+ go func() {
17+ for {
18+ <-sighup
19+ handler()
20+ }
21+ }()
22+}
23+24+func WaitForInterrupt() {
25+ sigint := make(chan os.Signal, 1)
26+ signal.Notify(sigint, syscall.SIGINT, syscall.SIGTERM)
27+ <-sigint
28+ signal.Stop(sigint)
29+}
-13
src/signal_other.go
···1-//go:build !unix
2-3-package git_pages
4-5-func OnReload(handler func()) {
6- // not implemented
7-}
8-9-func WaitForInterrupt() {
10- for {
11- // Ctrl+C not supported
12- }
13-}