proc-tree
Linux process tree — snapshot from /proc, incremental maintenance via fork/exec/exit events, ancestry chain queries, and pstree-style display.
Overview
proc-tree provides a unified interface for maintaining a Linux process tree with O(1) child lookups, incremental updates from process events, and ancestry chain queries. It supports both one-shot snapshots from /proc and real-time updates via fork/exec/exit events, with PID reuse detection and thread-safe storage.
Why proc-tree?
Unlike simple process listing tools that only show a point-in-time snapshot, proc-tree maintains an in-memory process tree that can be incrementally updated as processes fork, exec, and exit. This makes it ideal for tools that need to track process hierarchies over time, build ancestry chains, or find processes by name or user. The library's unified storage interface and zero-allocation iteration patterns make it suitable for high-performance system monitoring applications.
Usage
Add to your Cargo.toml:
[]
= "0.4.0"
Requirements
- Linux with
/procfilesystem - No special capabilities required for snapshot mode
CAP_NET_ADMINfor real-time event updates via proc-connector
Quick start
use ;
let store = new; // TTL in seconds
snapshot.expect;
// Resolve any PID
let info = resolve.unwrap;
println!;
// Render pstree-style tree
println!;
Serde support
Enable the serde feature to serialize/deserialize ProcessInfo:
[]
= { = "0.4.0", = ["serde"] }