#process #process-id #querying #port #helper #find #ctl

bin+lib proc-ctl

A helper library for querying and manipulating processes

6 releases (3 breaking)

0.4.0 Nov 6, 2024
0.3.0 Apr 12, 2024
0.2.1 May 3, 2023
0.1.1 May 2, 2023

#223 in Unix APIs

Download history 7/week @ 2024-09-21 133/week @ 2024-11-02 31/week @ 2024-11-09 3/week @ 2024-11-16 1/week @ 2024-11-23

168 downloads per month

MPL-2.0 license

34KB
759 lines

proc-ctl

A helper library for querying and manipulating processes.

Find what port a process is using

use proc_ctl::PortQuery;

let query = PortQuery::new()
    .tcp_only()
    .ip_v4_only()
    .process_id(55932) // Get a process ID from somewhere
    .expect_min_num_ports(1);

query.execute().unwrap();

Find processes by name

use proc_ctl::{ProcCtlResult, ProcQuery};

fn main() -> ProcCtlResult<()> {

    let query = ProcQuery::new()
        .process_name("firefox");

    let processes = query.list_processes()?;
    Ok(())
}

Find the children of a given process

use proc_ctl::{ProcCtlResult, ProcQuery};

fn main() -> ProcCtlResult<()> {
    let query = ProcQuery::new()
        .process_id(55932) // Get a process ID from somewhere
        .expect_min_num_children(1);

    query.children()?;
    Ok(())
}

Dependencies

~0.2–41MB
~645K SLoC