Skip to content

The agent that grows with you

refactor(serve): one place maps "process gone" to orphaned in the watchdog

kshitijk4poor2423385c059f
diff --git a/hermes_cli/web_server_lifecycle.py b/hermes_cli/web_server_lifecycle.py
index b9eb0d9c441..78dcafdf666 100644
--- a/hermes_cli/web_server_lifecycle.py
+++ b/hermes_cli/web_server_lifecycle.py
@@ -75,9 +75,8 @@ def _process_start_marker(pid: int) -> str:
marker = result.stdout.strip()
if result.returncode == 0 and marker:
return f"ps:{marker}"
- # rc==1 with empty output is the portable "no such pid"; "No such process" widens that for ps
- # builds that say so explicitly. Any other failure stays an OSError so the watchdog degrades to
- # pid liveness instead of exiting on a healthy backend.
+ # Only known "missing pid" signals become ProcessLookupError; anything else stays OSError so the
+ # watchdog degrades to pid liveness instead of exiting on a healthy backend.
if (result.returncode == 1 and not marker) or "no such process" in result.stderr.lower():
raise ProcessLookupError(pid)
raise OSError(f"ps could not inspect PID {pid}: {result.stderr.strip()}")
@@ -300,8 +299,6 @@ def _is_serve_orphaned(
pid_exists = _pid_exists
return not bool(pid_exists(int(desktop_pid)))
- except ProcessLookupError:
- return True
except Exception:
return False
diff --git a/tests/hermes_cli/test_serve_parent_watchdog.py b/tests/hermes_cli/test_serve_parent_watchdog.py
index 4ad394a9766..95cb895cfe3 100644
--- a/tests/hermes_cli/test_serve_parent_watchdog.py
+++ b/tests/hermes_cli/test_serve_parent_watchdog.py
@@ -183,7 +183,7 @@ def test_parent_watchdog_degrades_to_pid_liveness_when_marker_probe_raises_oserr
"""#80204: a probe failure must fall through to ``pid_exists`` instead of pinning the
watchdog to "not orphaned" forever on a dead Desktop parent."""
def broken_marker_probe(pid: int) -> str:
- raise OSError(f"ps could not inspect PID {pid}: ps: {pid}: No such process")
+ raise OSError(f"ps could not inspect PID {pid}: process table temporarily unavailable")
marker = "ps:Thu Aug 20 22:33:11 2026"
assert _is_serve_orphaned(4242, marker, pid_exists=lambda _pid: False,