Skip to main content

read_proc_comm

Function read_proc_comm 

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

Read the command name for a PID from /proc/{pid}/comm.

Returns None if the process doesn’t exist or the file can’t be read.

use proc_tree::proc::read_proc_comm;

let comm = read_proc_comm(1).unwrap();
assert!(!comm.is_empty()); // PID 1 is always init/systemd
assert!(read_proc_comm(0xFFFF_FFFF).is_none());