add WorkDir column support on macOS - #969
Open
eigenigma wants to merge 2 commits into
Open
Conversation
The Linux block and the Windows block had the same add() body and only differed in how the path was looked up. Give both a work_dir_of(pid, procfs) with the same signature and keep a single impl Column. The procfs field is then read on every platform, so the dead_code allow on it can go, and the nested if-let ladder on Linux collapses to two lines. No behaviour change: None and "" already rendered as the same empty cell.
libproc's pidcwd() is still a stub on macOS that always returns Err, so this goes through proc_pidinfo(PROC_PIDVNODEPATHINFO) instead. libc already ships the proc_vnodepathinfo struct; wrapping it in a newtype that implements libproc's PIDInfo lets the column reuse the same pidinfo::<T>() path the rest of the macOS code uses. repr(transparent) is load-bearing there: pidinfo sizes its buffer by size_of::<T>(). The NUL-terminated c_char buffer is converted with util::ptr_to_cstr, which the FreeBSD columns already use, so its cfg is widened to macOS. The lookup happens in the column's add() rather than in collect_proc, same as the Windows implementation, so the extra syscall per process is only paid when the column is actually shown. Processes owned by other users come back empty unless running as root, matching how the rest of the macOS columns behave.
eigenigma
marked this pull request as ready for review
September 7, 2026 18:17
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.
libproc's
pidcwd()is still a stub on macOS (it always returnsErr), so thecolumn goes through
proc_pidinfo(PROC_PIDVNODEPATHINFO)directly. libc alreadyships
proc_vnodepathinfo, so all that's needed is a#[repr(transparent)]newtype implementing libproc's
PIDInfo, and the column can use the samepidinfo::<T>()call the rest ofprocess/macos.rsuses. No new dependencies.The first commit is a small cleanup of
work_dir.rs: the Linux and Windowsblocks had identical
add()bodies and only differed in how the path is lookedup, so now there's one
impl Columnand a per-platformwork_dir_of(pid, procfs). No behaviour change, and it drops the#[allow(dead_code)]on theprocfsfield. I only have a Mac here, so CI isthe real check for that commit on Linux/Windows.
The lookup happens lazily in
add()like the Windows implementation, so nothingis paid unless the column is actually configured. Other users' processes come
back empty without root, same as the other macOS columns.
Also flips the macOS cell in the README support matrix and adds a CHANGELOG
line.
Tested on macOS 26 / arm64:
procs -i WorkDirshows/for system daemons andthe right cwd for my shells,
cargo testpasses, clippy and fmt are clean (theremaining warnings are the pre-existing
unsafe_op_in_unsafe_fnones inprocess/macos.rsandutil.rs).