Skip to main content

pid_cmdline

Function pid_cmdline 

Source
pub fn pid_cmdline(pid: u32) -> Option<String>
Expand description

Return the command line of a specific pid, or None if the pid is missing / unreadable / exited between query and answer.

v0.14.2 (#162 diagnostic, post-supervisor #170): when wire status surfaces orphan pids, the operator wants to know “which session is that daemon serving?” without grepping ps themselves — closes the launchd-vs-session-isolation diagnostic gap honey-pine burned multiple sessions on.

  • Linux: read /proc/<pid>/cmdline (NUL-separated, replace with spaces).
  • macOS / BSD: ps -p <pid> -o command= (no header, single column).
  • Windows: PowerShell CIM Get-CimInstance Win32_Process | Where {$_.ProcessId -eq <pid>} | Select CommandLine.

Conservative on failure: returns None rather than synthesizing a placeholder. Callers should treat None as “annotation unavailable”, not “process is dead” — process_alive is the liveness oracle.