Skip to content

The agent that grows with you

chore(process): the supervisor refuses a malformed parent pgid; two comments match the code again

kshitijk4pooredbb589c60a6
diff --git a/hermes_cli/process_supervisor.sh b/hermes_cli/process_supervisor.sh
index c9f61e8563e..c8a25e35f3c 100755
--- a/hermes_cli/process_supervisor.sh
+++ b/hermes_cli/process_supervisor.sh
@@ -22,6 +22,8 @@
trap '' INT HUP # a dying parent's SIGINT/SIGHUP must not preempt the reap: EOF is the only signal
parent=$1
+# Every register line compares against it: a bad value would silently refuse every registration.
+case $parent in ''|*[!0-9]*) echo "hermes process supervisor: bad parent pgid '$parent'; refusing to run" >&2; exit 2 ;; esac
# Run inside the parent's group, a killpg of the parent would take us down before we reap.
kill -0 -$$ 2>/dev/null || {
echo "hermes process supervisor: not a process-group leader; refusing to run" >&2
diff --git a/plugins/web/ddgs/provider.py b/plugins/web/ddgs/provider.py
index 7ed8eb32d76..c96061c85ff 100644
--- a/plugins/web/ddgs/provider.py
+++ b/plugins/web/ddgs/provider.py
@@ -110,7 +110,7 @@ def _spawn_worker(env: dict[str, str]) -> subprocess.Popen:
env["PYTHONPATH"] = path_entry + os.pathsep + child_pythonpath if child_pythonpath else path_entry
worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "_search_worker.py")
# Own process group/session so terminate/kill also reach a hung primp grandchild.
- # detached-spawn: ok — awaited under a 30 s cap that kills its group; blocked on its stdin pipe, it exits on owner death
+ # detached-spawn: ok — awaited under a 30 s cap that kills its group; an owner killed mid-search leaves it to finish that one search
extra_kwargs: dict[str, Any] = {"creationflags": subprocess.CREATE_NEW_PROCESS_GROUP} if sys.platform == "win32" else {"start_new_session": True}
# stdin/stdout/stderr stay explicit keyword args so scripts/check_subprocess_stdin.py sees them
# (TUI gateway inherits stdin). stderr=DEVNULL: a chatty child would deadlock a stdout-only drain.
diff --git a/tests/hermes_cli/test_process_identity_supervisor.py b/tests/hermes_cli/test_process_identity_supervisor.py
index 16b436705a3..4f0474c744a 100644
--- a/tests/hermes_cli/test_process_identity_supervisor.py
+++ b/tests/hermes_cli/test_process_identity_supervisor.py
@@ -816,3 +816,11 @@ def test_no_pgids_is_a_no_op(monkeypatch):
process_identity.own_process_groups([])
assert spawned == []
+
+
[email protected]("parent", ["", "12x"])
+def test_the_supervisor_refuses_a_malformed_parent_pgid(parent):
+ """Every register line is compared with it, so a bad value would silently refuse them all."""
+ run = subprocess.run([process_identity._POSIX_SH, str(process_identity._SUPERVISOR_SCRIPT), parent],
+ input="", capture_output=True, text=True, timeout=10, check=False)
+ assert run.returncode == 2 and "bad parent pgid" in run.stderr
diff --git a/tools/mcp_tool_lifecycle.py b/tools/mcp_tool_lifecycle.py
index 42887568697..4f06c10640b 100644
--- a/tools/mcp_tool_lifecycle.py
+++ b/tools/mcp_tool_lifecycle.py
@@ -78,8 +78,9 @@ def _snapshot_child_pids() -> set:
# argv markers of non-MCP gateway children that can race into the snapshot delta during an
-# MCP spawn (defense-in-depth; LSP/slash_worker already use start_new_session). Matched against
-# argv[1:] because Python/Java children start with the interpreter path.
+# MCP spawn (defense-in-depth: LSP servers and the slash worker lead their own groups under the
+# owner-death supervisor, see spawn_owned). Matched against argv[1:] because Python/Java children
+# start with the interpreter path.
_NON_MCP_CHILD_CMDLINE_MARKERS: tuple[str, ...] = (
"tui_gateway.slash_worker", "tui_gateway.entry",
"-dorg.eclipse.equinox.launcher", "eclipse.jdt.ls", "org.eclipse.equinox.launcher_", # jdtls