Repository navigation
darwin: respect the update_process_names setting - #2141
cabhinaba3 wants to merge 1 commit into
Conversation
"Update process names on every refresh" had no effect on Darwin, because the command line and executable were only read when a process was first seen. Re-read both for known processes when the setting is on, as Linux does, so that renamed and re-exec'd processes are shown correctly. Zombies are skipped, as on Linux: their arguments can no longer be read, and the fallback would replace the full command line with p_comm. Fixes htop-dev#915 Assisted-by: Claude Opus 5.5 Signed-off-by: Abhinaba Chakraborty <abhinabacr4@gmail.com>
Walkthrough
Priority: Change: Bug fix · Severity of issue fixed: Medium Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
3191d125-bde4-4e82-a15b-ff9d9faa9737
Files selected for processing: 1-
darwin/DarwinProcess.c
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
-
|
@BenBE, can you have a look when you have some time? Thanks |
darwin: respect the update_process_names setting
Fixes #915.
On Darwin, "Update process names on every refresh" had no effect.
DarwinProcess_setFromKInfoProc()read the command line once.With the necessary setting on, both are now re-read for processes htop already knows about, as Linux does (
LinuxProcessTable_readCmdlineFile()also refreshes the binary). Zombies are skipped, as on Linux: their arguments can no longer be read, and the fallback would shrink the full command line top_comm.With the setting off, nothing changes.
Before
htop stays at
count=0whilepsshows the process renaming itself every second.After
htop follows the process, matching
psat the same second.Exec and zombie
A process that
execs/bin/sleepunder the same PID is shown assleep 60. A zombie keeps its full command line whilepsshows<defunct>.How to test
A process that rewrites its own
argv[1]once a second:Enable the option under F2, Display options:
The Command column should now follow
ps -o command= -p <pid>.Tested
On macOS 26.6.2 (Apple M1)
Note:
With the setting on, the extra reads cost about 9 ms of CPU per refresh with ~530 processes.
Assisted-by: Claude Opus 5.5