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

Signed-off-by: Nick Khyl <[email protected]>
This commit is contained in:
Nick Khyl committed 2026-11-19 19:36:03 -08:00
1 parent 2e8f381c2e
commit 09417bf73d
1 file changed
+8 -1
+8 -1
View File
@@ -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, _ := os.Executable(); 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)