From aa474d362348248970090e22d476d1716723fae1 Mon Sep 17 00:00:00 2001 From: "Matt T. Proud" Date: Sun, 6 Jan 2013 23:30:46 +0100 Subject: [PATCH] Improve interruption handling. --- main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 1a29e6ad4..860ec1864 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,7 @@ import ( "log" "net/http" "os" + "os/signal" "time" ) @@ -30,10 +31,16 @@ func main() { os.Exit(1) } - defer func() { + go func() { + notifier := make(chan os.Signal) + signal.Notify(notifier, os.Interrupt) + <-notifier m.Close() + os.Exit(0) }() + defer m.Close() + results := make(chan retrieval.Result, 4096) t := &retrieval.Target{