summaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2025-06-14 01:29:40 +0200
committerThomas Voss <mail@thomasvoss.com> 2025-06-14 01:29:40 +0200
commit5a12e3e229e112e6b316c9ee9f762e36f321271d (patch)
tree7222853ee2a008643e079e7f32d24edfcef2227a /main.go
parent940fe703931f0aa97f68593340d0925af19187ee (diff)
Call atexit handlers on SIGINT and SIGTERMHEADmaster
Diffstat (limited to 'main.go')
-rw-r--r--main.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/main.go b/main.go
index fdde5e8..a9b9ea7 100644
--- a/main.go
+++ b/main.go
@@ -6,6 +6,7 @@ package main
import (
"flag"
"os"
+ "os/signal"
"path/filepath"
"syscall"
@@ -39,6 +40,14 @@ func main() {
"database name or ‘:memory:’ for an in-memory database")
flag.Parse()
+ sigs := make(chan os.Signal, 1)
+ signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
+ go func() {
+ <-sigs
+ atexit.Exec()
+ os.Exit(0)
+ }()
+
if *debugp {
path := Try2(os.Executable())
go watch.File(path, func() {