1
0
mirror of https://git.zx2c4.com/wireguard-go synced 2024-11-15 01:05:15 +01:00

Minor main.go signal fixes

* 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>
This commit is contained in:
Filippo Valsorda 2018-05-20 23:39:25 -04:00 committed by Jason A. Donenfeld
parent 7a527f7c89
commit bc05eb1c3c

View File

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