From d17f96b586a39c0e8945e78e4d5a4dcc992e90cf Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 13 Apr 2021 08:34:37 -0700 Subject: [PATCH] cmd/tailscale/cli: restore SIGINT/SIGTERM on context cancel This fixes Ctrl-C not interrupting "tailscale push". Signed-off-by: Brad Fitzpatrick --- cmd/tailscale/cli/cli.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/tailscale/cli/cli.go b/cmd/tailscale/cli/cli.go index d3ba7a5a1..fdaa46111 100644 --- a/cmd/tailscale/cli/cli.go +++ b/cmd/tailscale/cli/cli.go @@ -126,7 +126,13 @@ func connect(ctx context.Context) (net.Conn, *ipn.BackendClient, context.Context go func() { interrupt := make(chan os.Signal, 1) 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() cancel() }()