fix(gateway): exclude CLI invoker ancestor chain in _append_unique_pid#13273
Closed
hclsys wants to merge 1 commit into
Closed
fix(gateway): exclude CLI invoker ancestor chain in _append_unique_pid#13273hclsys wants to merge 1 commit into
hclsys wants to merge 1 commit into
Conversation
Reporter @yes999zc in NousResearch#13242: `hermes gateway run` from an interactive CLI session got false-positive 'already running' and shut down immediately. The `ps aux` scan in `_scan_gateway_pids` matches generic substrings like 'hermes_cli.main gateway', which picks up the invoking CLI process AND its ancestor chain (parent shell, tmux session, launcher). `_append_unique_pid` already filtered `os.getpid()` but not the ancestor chain. The repo already has an ancestor-detection helper (`_is_pid_ancestor_of_current_process`) used by `_request_gateway_self_restart`; extend `_append_unique_pid` to reuse it, so CLI-invoker self-matches are filtered at the same point that covers `find_gateway_pids`, service probes, and scan results. Fixes NousResearch#13242
Author
|
Closing as stale per personal cycle policy: 20h ceiling with zero maintainer movement (no comment, no review, no label). If this becomes relevant again I'll re-open with a fresh rebase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
`hermes gateway run` invoked from an interactive CLI session gets a self false-positive: the `ps aux` scan in `_scan_gateway_pids` matches generic substrings like `hermes_cli.main gateway`, which picks up the invoking CLI process AND its ancestor chain (parent shell, tmux session, launcher wrapper). The gateway then concludes it's 'already running' and shuts down immediately.
Reported by @yes999zc in #13242.
Fix
`_append_unique_pid` already filtered `os.getpid()` but not the ancestor chain. The repo already has an ancestor-detection helper `_is_pid_ancestor_of_current_process` used by `_request_gateway_self_restart`. Extend `_append_unique_pid` to reuse it — one gate, covers every call site (`find_gateway_pids`, service probes, `_scan_gateway_pids`).
Pre-implement audit
Testing
Fixes #13242