processes/
processes.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::io;

// NOTE: It's better to run this example with `sudo` or at least with a SUID bit,
// because some functions will return `Operation not permitted` for any pid given.

fn main() -> io::Result<()> {
    let pids = darwin_libproc::all_pids()?;
    for pid in pids {
        println!("PID: #{}", pid);
        println!("\tName: {:?}", darwin_libproc::name(pid)?);
        println!("\tPath: {:?}", darwin_libproc::pid_path(pid)?);
    }

    Ok(())
}