mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-24 10:52:21 +00:00
The stdio-MCP orphan reaper (`_kill_orphaned_mcp_children`) and the local environment's `_kill_process` both signalled a process *group* via `os.killpg(pgid, sig)` using a PGID captured at spawn time. Once the original child exits and is reaped, the kernel can recycle that PID/PGID onto an unrelated process group, so a later sweep would `killpg` a stranger. Observed in the wild: a long-running gateway reaped a recycled PGID that had landed on a desktop browser's session leader, SIGTERM-ing Firefox at irregular intervals (proven with the kernel `signal:signal_generate` tracepoint — `comm=firefox` killed by the hermes gateway via a recycled group id). Fix: record each leader's start time (`/proc/<pid>/stat` field 22, via the existing `gateway.status.get_process_start_time`) alongside the PGID, and re-check it before signalling. A PGID whose leader's start time no longer matches — or whose leader is gone — is never signalled. When no start time is available (e.g. macOS has no /proc) the guard degrades to the prior best-effort behaviour, so non-Linux platforms are unaffected. Adds regression tests covering both the recycled-PID (skip) and matching-PID (signal) paths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| base.py | ||
| daytona.py | ||
| docker.py | ||
| file_sync.py | ||
| local.py | ||
| managed_modal.py | ||
| modal.py | ||
| modal_utils.py | ||
| singularity.py | ||
| ssh.py | ||