pub fn pidpath(pid: i32) -> Result<String, String>Expand description
Get the path of the executable file being run for a process
§Errors
Will return Err if not run as root or the underlying linux readlink method returns
a non-zero value and sets errno
§Examples
use libproc::libproc::proc_pid::{pidpath, am_root};
match pidpath(1) {
Ok(path) => println!("Path of init process with PID = 1 is '{}'", path),
Err(_) if !am_root() => println!("pidpath() needs to be run as root"),
Err(err) if am_root() => eprintln!("Error: {}", err),
_ => panic!("Unknown error")
}