summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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() {