From 69306226eaef3dfd558ce3e94ba9f5aaacf62d3d Mon Sep 17 00:00:00 2001 From: Nick Khyl Date: Thu, 19 Nov 2026 19:36:03 -0800 Subject: [PATCH] clientupdate: don't exit tailscaled when starting the Windows installer When an update is requested via LocalAPI, updateWindows runs inside tailscaled, and its os.Exit(0) after launching the tailscale.exe copy made the service restart the tailscaled child process immediately. Exit only when running as tailscale.exe. In tailscaled.exe, wait for the installer instead, which stops the service as part of the upgrade. As a side effect, an install that fails before stopping the service is now reported as a failed update. Updates tailscale/corp#40430 Change-Id: I8af60fa12740dafceb7c9ea4f50d87c1cad27fa4 Signed-off-by: Nick Khyl --- clientupdate/clientupdate_windows.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/clientupdate/clientupdate_windows.go b/clientupdate/clientupdate_windows.go index de6b5d50f..c76c4153d 100644 --- a/clientupdate/clientupdate_windows.go +++ b/clientupdate/clientupdate_windows.go @@ -159,7 +159,7 @@ you can run the command prompt as Administrator one of these ways: up.Logf("making tailscale.exe copy to switch to...") up.cleanupOldDownloads(filepath.Join(os.TempDir(), updaterPrefix+"-*.exe")) - _, cmdTailscaleCopy, err := makeCmdTailscaleCopy() + cmdTailscale, cmdTailscaleCopy, err := makeCmdTailscaleCopy() if err != nil { return err } @@ -174,6 +174,13 @@ you can run the command prompt as Administrator one of these ways: if err := cmd.Start(); err != nil { return err } + if selfExe, err := os.Executable(); err == nil && selfExe != cmdTailscale { + // We're tailscaled (the service's child process) rather + // than tailscale (the CLI). If we exited now, the service + // would restart us right away (see babysitProc in cmd/tailscaled), + // so keep running until the installer stops the service. + return cmd.Wait() + } // Once it's started, exit ourselves, so the binary is free // to be replaced. os.Exit(0)