fix: poll process via Signal(0) in stopDaemon for PID reuse safety
Some checks failed
Deploy / build (push) Failing after 4s
Security Scan / security (push) Successful in 11s

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-09 15:10:48 +00:00
parent fd8cd31b76
commit 79e6587d8a

View file

@ -175,9 +175,13 @@ func stopDaemon(reg *process.Registry, code, daemon string) error {
}
// Wait for process to exit, escalate to SIGKILL after 30s.
// Poll the process directly via Signal(0) rather than relying on
// the daemon to self-unregister, which avoids PID reuse issues.
deadline := time.Now().Add(30 * time.Second)
for time.Now().Before(deadline) {
if _, still := reg.Get(code, daemon); !still {
if err := proc.Signal(syscall.Signal(0)); err != nil {
// Process is gone.
_ = reg.Unregister(code, daemon)
cli.LogInfo(fmt.Sprintf("Stopped %s/%s (PID %d)", code, daemon, entry.PID))
return nil
}