Merge pull request #23 from matttproud/feature/signal-handling

Improve interruption handling.
This commit is contained in:
juliusv 2013-01-07 02:25:35 -08:00
commit 51bf3917df

View file

@ -20,6 +20,7 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"os/signal"
"time" "time"
) )
@ -30,10 +31,16 @@ func main() {
os.Exit(1) os.Exit(1)
} }
defer func() { go func() {
notifier := make(chan os.Signal)
signal.Notify(notifier, os.Interrupt)
<-notifier
m.Close() m.Close()
os.Exit(0)
}() }()
defer m.Close()
results := make(chan retrieval.Result, 4096) results := make(chan retrieval.Result, 4096)
t := &retrieval.Target{ t := &retrieval.Target{