Crate pid_set

source ·
Expand description

§PID Set Library

pid_set is a library for managing and monitoring process identifiers (PIDs) using epoll on Linux. It allows for asynchronous notification when a process exits by leveraging epoll and pidfd (process file descriptors).

§Features

  • Create a PidSet to manage multiple PIDs.
  • Monitor process exits using epoll.
  • Handle system call errors gracefully with custom errors.

§Usage

Add this to your Cargo.toml:

[dependencies]
pid_set = "0.1.0"

§Examples

Here’s how you can use PidSet to monitor a list of PIDs:

use pid_set::{PidSet, PidSetError};

fn main() -> Result<(), PidSetError> {
    let pids = vec![1234, 5678, 431, 9871, 2123]; // Example PIDs
    let mut pid_set = PidSet::new(pids)?;

    // Wait for any PID to exit
    pid_set.wait_any()?;

    // Clean up
    pid_set.close()?;
    Ok(())
}

Structs§

  • Manages a set of PIDs and their corresponding epoll file descriptors.

Enums§