Skip to content

The agent that grows with you

fix: use psutil.pid_exists for orphan-reap liveness probe (Windows footgun lint)

Teknium9b1a2a14ca4a
diff --git a/hermes_cli/dashboard_procs.py b/hermes_cli/dashboard_procs.py
index 70a8564cedb..35a047f6f1b 100644
--- a/hermes_cli/dashboard_procs.py
+++ b/hermes_cli/dashboard_procs.py
@@ -770,15 +770,16 @@ def _reap_orphaned_desktop_local_serves(
# Brief grace, then SIGKILL survivors.
sleep_fn(1.5)
+ # psutil.pid_exists for the liveness probe: os.kill(pid, 0) is a
+ # Windows footgun (sends CTRL_C_EVENT, bpo-14484). This path is
+ # POSIX-only (win32 early-returns above), but the linter blocks the
+ # pattern everywhere and psutil is a core dependency anyway.
+ import psutil
+
for pid, _cmd in targets:
if pid in failed:
continue
- try:
- os.kill(pid, 0)
- except ProcessLookupError:
- killed.append(pid)
- continue
- except OSError:
+ if not psutil.pid_exists(pid):
killed.append(pid)
continue
try: