Skip to main content

display

Function display 

Source
pub fn display(store: &impl ProcessStore, root_pid: u32) -> String
Expand description

Render a pstree-style display starting from the given root PID.

use proc_tree::{DefaultStore, display, ProcessStore, ProcessInfo};

let store = DefaultStore::new(0);
store.insert_process(1, ProcessInfo { ppid: 0, cmd: "init".into(), user: "root".into(), tgid: 1, start_time_ns: 0 });
store.insert_process(100, ProcessInfo { ppid: 1, cmd: "sshd".into(), user: "root".into(), tgid: 100, start_time_ns: 0 });
store.insert_process(200, ProcessInfo { ppid: 1, cmd: "cron".into(), user: "root".into(), tgid: 200, start_time_ns: 0 });

let output = display(&store, 1);
assert!(output.starts_with("init"));
assert!(output.contains("sshd"));
assert!(output.contains("cron"));