fix: poll process via Signal(0) in stopDaemon for PID reuse safety
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
fd8cd31b76
commit
79e6587d8a
1 changed files with 5 additions and 1 deletions
|
|
@ -175,9 +175,13 @@ func stopDaemon(reg *process.Registry, code, daemon string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for process to exit, escalate to SIGKILL after 30s.
|
// 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)
|
deadline := time.Now().Add(30 * time.Second)
|
||||||
for time.Now().Before(deadline) {
|
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))
|
cli.LogInfo(fmt.Sprintf("Stopped %s/%s (PID %d)", code, daemon, entry.PID))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue