]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
Minor main.go signal fixes
authorFilippo Valsorda <hi@filippo.io>
Mon, 21 May 2018 03:39:25 +0000 (23:39 -0400)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 21 May 2018 18:22:12 +0000 (20:22 +0200)
* Buffer the signal channel as it's non-blocking on the sender side
* Notify on SIGTERM instead of the uncatchable SIGKILL

License: MIT
Signed-off-by: Filippo Valsorda <valsorda@google.com>
main.go

diff --git a/main.go b/main.go
index 343e585d667706245a63017540acc20e12ce564c..523a92787a747e9d7732d7354ec62efb7c28977e 100644 (file)
--- a/main.go
+++ b/main.go
@@ -12,6 +12,7 @@ import (
        "os/signal"
        "runtime"
        "strconv"
+       "syscall"
 )
 
 const (
@@ -236,7 +237,7 @@ func main() {
        logger.Info.Println("Device started")
 
        errs := make(chan error)
-       term := make(chan os.Signal)
+       term := make(chan os.Signal, 1)
 
        uapi, err := UAPIListen(interfaceName, fileUAPI)
        if err != nil {
@@ -259,7 +260,7 @@ func main() {
 
        // wait for program to terminate
 
-       signal.Notify(term, os.Kill)
+       signal.Notify(term, syscall.SIGTERM)
        signal.Notify(term, os.Interrupt)
 
        select {