Files
thomasandClaude Opus 4.8 13608269b3 fix(windows): stop the daemon before install/uninstall so it can replace tty7.exe
The persistent daemon (`tty7.exe --daemon`) is a detached background process
that outlives the GUI and is the running image of tty7.exe, so Windows locks
the file. An upgrade or uninstall then can't overwrite/remove the binary and
fails ("file in use" / reboot required) — the Restart Manager doesn't reliably
catch a no-window, DETACHED_PROCESS daemon in its own process group.

- spawn: extract the "stop the running daemon" half of `restart()` into a
  reusable `stop()` (Shutdown -> await exit -> pid reap fallback -> clear
  endpoint); `restart()` is now `stop()` + `ensure_running()`.
- main: add a `--stop-daemon` CLI entry that runs `stop()` and returns before
  any GUI init, so it never opens a window.
- installer: in PrepareToInstall, extract the *new* tty7.exe to {tmp} and run
  `--stop-daemon` (the new binary understands the flag; an old installed one
  would launch the GUI instead), releasing the lock before file copy. Mirror it
  in [UninstallRun]. Keep CloseApplications as a backstop but RestartApplications=no
  (the GUI respawns the daemon on next start).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 22:17:51 +08:00
..