pub fn handle_events(
store: &impl ProcessStore,
events: &[ProcEvent],
) -> Vec<ExitedProcess>Expand description
Handle a batch of process lifecycle events.
Returns ExitedProcess handles for Exit events. The process info stays in the store
— callers decide when to remove it via ExitedProcess::remove.
This is critical for event-driven systems where file events (fanotify) may arrive after the proc connector exit event but still need to look up process info.
§Example
use proc_tree::{DefaultStore, handle_events, ProcEvent, ProcessStore};
let store = DefaultStore::new(0);
// Fork creates a process
let exited = handle_events(&store, &[
ProcEvent::Fork { child_pid: 200, parent_pid: 100, timestamp_ns: 0 },
]);
assert!(exited.is_empty());
// Exit returns ExitedProcess handle — process info stays in store
let exited = handle_events(&store, &[
ProcEvent::Exit { pid: 200 },
]);
assert_eq!(exited[0].pid, 200);
assert!(store.get_process(200).is_some());
// Caller explicitly removes when done
for ep in exited {
ep.remove(&store);
}
assert!(store.get_process(200).is_none());