The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): wrapper keeps forwarding signals until the child has exited; test runs on every POSIX lane
kshitijk4poorce90424ee15d
diff --git a/hermes_cli/stderr_timestamp.py b/hermes_cli/stderr_timestamp.pyindex 4f1cb232594..c45464521a9 100644--- a/hermes_cli/stderr_timestamp.py+++ b/hermes_cli/stderr_timestamp.py@@ -142,11 +142,13 @@ def main(argv: Sequence[str] | None = None) -> int:previous_handlers = _install_signal_forwarders(proc)try:_copy_stderr_with_timestamps(proc.stderr, log_path)- finally:proc.stderr.close()+ # Keep forwarding until the child has actually exited: a signal that lands between+ # its stderr EOF and wait() would otherwise kill the wrapper with the default action.+ returncode = proc.wait()+ finally:for signum, handler in previous_handlers.items():signal.signal(signum, handler)- returncode = proc.wait()return _child_returncode_for_supervisor(args.command, returncode)diff --git a/tests/hermes_cli/test_stderr_timestamp.py b/tests/hermes_cli/test_stderr_timestamp.pyindex c4ef78cc024..f375d6cff1f 100644--- a/tests/hermes_cli/test_stderr_timestamp.py+++ b/tests/hermes_cli/test_stderr_timestamp.py@@ -215,7 +215,7 @@ def test_main_maps_gateway_ex_config_to_clean_stop(tmp_path):[email protected]_only[email protected](sys.platform == "win32", reason="POSIX signals")def test_wrapper_forwards_sigusr1_restart_request_to_child(tmp_path):"""Regression for #101426: launchd owns the wrapper's PID, so ``hermes update`` sends itsdrain-aware SIGUSR1 to the wrapper. It must reach the gateway child and the wrapper must@@ -239,6 +239,7 @@ def test_wrapper_forwards_sigusr1_restart_request_to_child(tmp_path):[sys.executable, "-m", "hermes_cli.stderr_timestamp", "--error-log", str(log_path), "--",sys.executable, "-c", child],stderr=subprocess.DEVNULL,+ start_new_session=True,)try:deadline = time.monotonic() + 10@@ -248,8 +249,12 @@ def test_wrapper_forwards_sigusr1_restart_request_to_child(tmp_path):os.kill(wrapper.pid, signal.SIGUSR1)rc = wrapper.wait(timeout=10)finally:- if wrapper.poll() is None:- wrapper.kill()+ # Kill the whole session: on a red run the wrapper dies of the signal and the child+ # would otherwise keep sleeping.+ try:+ os.killpg(wrapper.pid, signal.SIGKILL)+ except ProcessLookupError:+ passassert rc == GATEWAY_SERVICE_RESTART_EXIT_CODEassert "restart requested" in log_path.read_text(encoding="utf-8")