From 6da812b4cf446d9890422bbe46e378407939f507 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 16 Apr 2021 08:00:31 -0700 Subject: [PATCH] cmd/tailscale/cli: avoid a spammy log message on SIGINT 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 fdaa46111..1a54bd723 100644 --- a/cmd/tailscale/cli/cli.go +++ b/cmd/tailscale/cli/cli.go @@ -24,6 +24,7 @@ import ( "tailscale.com/ipn" "tailscale.com/paths" "tailscale.com/safesocket" + "tailscale.com/syncs" ) // ActLikeCLI reports whether a GUI application should act like the @@ -109,6 +110,8 @@ var rootArgs struct { socket string } +var gotSignal syncs.AtomicBool + func connect(ctx context.Context) (net.Conn, *ipn.BackendClient, context.Context, context.CancelFunc) { c, err := safesocket.Connect(rootArgs.socket, 41112) if err != nil { @@ -133,6 +136,7 @@ func connect(ctx context.Context) (net.Conn, *ipn.BackendClient, context.Context signal.Reset(syscall.SIGINT, syscall.SIGTERM) return } + gotSignal.Set(true) c.Close() cancel() }() @@ -150,7 +154,9 @@ func pump(ctx context.Context, bc *ipn.BackendClient, conn net.Conn) { if ctx.Err() != nil { return } - log.Printf("ReadMsg: %v\n", err) + if !gotSignal.Get() { + log.Printf("ReadMsg: %v\n", err) + } break } bc.GotNotifyMsg(msg)