pub fn pids_by_type(filter: ProcFilter) -> Result<Vec<u32>>
Expand description

Returns the PIDs of active processes that match the given ProcFilter filter.

Examples

Get the list of all running process IDs using pids_by_type and ProcFilter::All:

use std::io::Write;
use libproc::processes;

if let Ok(pids) = processes::pids_by_type(processes::ProcFilter::All) {
    println!("There are {} processes running on this system", pids.len());
}

Get a list of running process IDs that are children of the current process:

use std::io::Write;
use std::process;
use libproc::processes;

let filter = processes::ProcFilter::ByParentProcess { ppid: process::id() };
if let Ok(pids) = processes::pids_by_type(filter) {
    println!("Found {} child processes of this process", pids.len());
}