Skip to content

fix(happy-cli): handle Windows PID reuse in daemon state check#809

Open
shenaibin789-glitch wants to merge 1 commit intoslopus:mainfrom
shenaibin789-glitch:fix/windows-daemon-pid-reuse
Open

fix(happy-cli): handle Windows PID reuse in daemon state check#809
shenaibin789-glitch wants to merge 1 commit intoslopus:mainfrom
shenaibin789-glitch:fix/windows-daemon-pid-reuse

Conversation

@shenaibin789-glitch
Copy link

Summary

  • On Windows, PIDs get reused after reboot. The daemon previously only checked if a PID was alive via process.kill(pid, 0), which could return true for a completely unrelated process that happened to receive the same PID after a system restart.
  • This caused the daemon to think it was already running and skip startup, leaving the device invisible on the mobile app.
  • Added an HTTP health check (POST /list) to the daemon's control server after the PID alive check. If the PID is alive but the HTTP ping fails, the stale state file is cleaned up, allowing a fresh daemon to start.

Test plan

  • Verified on Windows 10: after a full system reboot, the daemon correctly detects the stale PID and starts a new instance
  • Verified the mobile app can see the device after the daemon restarts
  • Verify on macOS/Linux that existing behavior is unchanged (PID reuse is less common but the HTTP check is harmless)

On Windows, PIDs get reused after reboot. The daemon state check
previously only verified if a PID was alive via process.kill(pid, 0),
which could return true for a completely unrelated process that was
assigned the same PID after a system restart.

This adds an HTTP health check to the daemon's control server after
the PID alive check. If the PID is alive but the HTTP ping fails,
the stale state is cleaned up, allowing a fresh daemon to start.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant