Skip to main content

snapshot

Function snapshot 

Source
pub fn snapshot(store: &impl ProcessStore) -> Result<(), Error>
Expand description

Snapshot all running processes from /proc.

Populates the store. Call once at startup before processing events.

§Errors

Returns an error if /proc cannot be read.

§Example

use proc_tree::{DefaultStore, snapshot, ProcessStore};

let store = DefaultStore::new(600);
snapshot(&store).expect("failed to read /proc");

// PID 1 should always exist on Linux
assert!(store.get_process(1).is_some());