Skip to content

The agent that grows with you

fix(process): log a supervisor that will not exit on release; the SIGKILL daemon test waits on the condition

kshitijk4poor9857b35c226f
diff --git a/hermes_cli/process_identity.py b/hermes_cli/process_identity.py
index 6f04c640221..6378c11d3bd 100644
--- a/hermes_cli/process_identity.py
+++ b/hermes_cli/process_identity.py
@@ -18,6 +18,7 @@ import json
import logging
import os
import platform
+import subprocess
import sys
import threading
import time
@@ -803,8 +804,6 @@ _POSIX_SH = "/bin/sh" if os.path.exists("/bin/sh") else "/system/bin/sh"
def _spawn_supervisor():
"""Start the per-process supervisor, or None if it cannot be started."""
- import subprocess
-
try:
# start_new_session=True is load-bearing: shutdown paths killpg this process's own group,
# which would kill the supervisor before it could reap anything. close_fds keeps the write
@@ -898,6 +897,6 @@ def update_supervised_pgids(verb: str, pgids) -> None:
# Reap it, or the exited supervisor stays a zombie until the next Popen in this process.
try:
proc.wait(timeout=5)
- except Exception:
- pass
+ except subprocess.TimeoutExpired:
+ logger.warning("owner-death supervisor pid %s did not exit 5 s after release", proc.pid)
_supervisor = None
diff --git a/tests/tools/test_browser_use_cli_owned_daemon.py b/tests/tools/test_browser_use_cli_owned_daemon.py
index 3ae8ec567e0..4bb1516296c 100644
--- a/tests/tools/test_browser_use_cli_owned_daemon.py
+++ b/tests/tools/test_browser_use_cli_owned_daemon.py
@@ -10,14 +10,22 @@ import json
import os
import subprocess
import sys
-import time
from pathlib import Path
import pytest
from hermes_cli import process_identity
+from tests.waiting import wait_until
from tools import browser_use_cli
+
+def _group_alive(pgid: int) -> bool:
+ try:
+ os.killpg(pgid, 0) # windows-footgun: ok — posix-marked test
+ except ProcessLookupError:
+ return False
+ return True
+
pytestmark = pytest.mark.platforms("posix")
# A stand-in harness daemon: the real module name on argv (the identity check reads argv), detached
@@ -126,15 +134,8 @@ def test_a_sigkilled_owner_takes_its_harness_daemon_with_it(tmp_path):
daemon_pid = int(owner.stdout.readline())
owner.kill()
owner.wait(timeout=10)
- deadline = time.monotonic() + 15
- while time.monotonic() < deadline:
- try:
- os.killpg(daemon_pid, 0) # windows-footgun: ok — posix-marked test
- except ProcessLookupError:
- break
- time.sleep(0.05)
- else:
- pytest.fail("the harness daemon outlived kill -9 of the Hermes process that drove it")
+ wait_until(lambda: not _group_alive(daemon_pid), timeout=15,
+ what="the harness daemon to die with the kill -9'd Hermes process that drove it")
finally:
if daemon_pid is not None:
try: