feat: set process title to 'hermes' in ps/top/htop - #35143
Merged
Conversation
Adds _set_process_title() in hermes_cli/main.py, called first thing in main(). Tries setproctitle (optional) for a full ps-args rewrite, then falls back to ctypes prctl(PR_SET_NAME) on Linux / pthread_setname_np on macOS. No-op on Windows and on any failure. No new dependency: the setproctitle path is best-effort via ImportError guard. Fixes #35108
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
1 |
First entries
hermes_cli/main.py:84: [unresolved-import] unresolved-import: Cannot resolve imported module `setproctitle`
✅ Fixed issues: none
Unchanged: 4920 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
Collaborator
tonydwb
approved these changes
May 30, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Overview
Clean implementation of process title setting with zero new dependencies. 45 additions across 2 files. Fallback strategy from setproctitle -> ctypes prctl on Linux -> pthread_setname_np on macOS -> no-op on Windows.
What's Right
- Zero new deps: setproctitle is optional (ImportError guard), falls back to ctypes
- Platform-aware: Linux prctl(PR_SET_NAME), Darwin pthread_setname_np, Windows no-op
- Non-fatal: wrapped in try/except at every level
- Proper placement: called first thing in main() before any I/O
- Comment block explains the strategy clearly
- AUTHOR_MAP update credits the original contributor
Safety Assessment
- No security concerns (cosmetic only)
- ctypes calls are well-documented with PR_SET_NAME = 15
- Thread name is limited to 16 bytes including null terminator ("hermes" is 6 bytes)
- No performance impact (runs once at startup)
Reviewed by Hermes Agent (cron)
1 task
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.
Summary
hermesnow shows up ashermesinps/top/htop/pgrep/docker topinstead ofpython3.xx.Salvage of #35111 by @wenchengxucool, with the mandatory
setproctitledependency dropped so this stays zero-new-deps.Changes
hermes_cli/main.py: new_set_process_title(), called first thing inmain().setproctitle(optional, best-effort viaImportErrorguard) — when present, rewrites the full command line so even theps auxargs column readshermes.prctl(PR_SET_NAME)on Linux /pthread_setname_npon macOS — sets the kernelcommfield (htop/top/ps -o comm/pgrep -x hermes/pkill hermes).scripts/release.py: AUTHOR_MAP entry for the contributor's commit email.No dependency added — the original PR made
setproctitlea hard core dep; we keep it strictly optional.Validation
Both paths exercised live on Linux against the worktree source:
/proc/self/commps -o argshermeshermeshermescommonly)Credit
Implementation by @wenchengxucool (#35111). The function design — try
setproctitle, fall back to ctypes — is theirs; we only removed the dependency add so it degrades gracefully whensetproctitleisn't installed.Infographic