cmd/tailscale/cli: restore SIGINT/SIGTERM on context cancel

This fixes Ctrl-C not interrupting "tailscale push".

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/1696/head
Brad Fitzpatrick 4 years ago
parent db5e269463
commit d17f96b586

@ -126,7 +126,13 @@ func connect(ctx context.Context) (net.Conn, *ipn.BackendClient, context.Context
go func() { go func() {
interrupt := make(chan os.Signal, 1) interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM) signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM)
<-interrupt select {
case <-interrupt:
case <-ctx.Done():
// Context canceled elsewhere.
signal.Reset(syscall.SIGINT, syscall.SIGTERM)
return
}
c.Close() c.Close()
cancel() cancel()
}() }()

Loading…
Cancel
Save