From 1a4351c626ee54058d03eae42f6af210faf56256 Mon Sep 17 00:00:00 2001 From: dingjun Date: Sat, 13 Apr 2019 16:05:55 +0800 Subject: [PATCH] add signal handler --- obfsshd/server.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/obfsshd/server.go b/obfsshd/server.go index dc665c8..ad4168a 100644 --- a/obfsshd/server.go +++ b/obfsshd/server.go @@ -9,6 +9,8 @@ import ( "io/ioutil" "net" "os" + "os/signal" + "syscall" "github.com/fangdingjun/go-log" "github.com/fangdingjun/obfssh" @@ -154,6 +156,12 @@ func main() { } }(lst) } - select {} + + ch := make(chan os.Signal, 2) + signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) + select { + case s := <-ch: + log.Printf("received signal %s, exit.", s) + } }