pub fn build_chain_string(
tree: &impl TreeStore,
cache: &impl CacheStore,
pid: u32,
) -> StringExpand description
Build a chain string from the process tree.
Format: "102|touch|root;101|sh|root;100|openclaw|root;1|systemd|root"
use proc_tree::{DefaultTree, DefaultCache, build_chain_string, TreeStore, CacheStore, PidNode, ProcInfo};
let tree = DefaultTree::new(100, 0);
let cache = DefaultCache::new(100, 0);
tree.insert_node(1, PidNode { ppid: 0, cmd: "init".into() });
cache.insert_info(1, ProcInfo { cmd: "init".into(), user: "root".into(), ppid: 0, tgid: 1, start_time_ns: 0 });
tree.insert_node(100, PidNode { ppid: 1, cmd: "sshd".into() });
cache.insert_info(100, ProcInfo { cmd: "sshd".into(), user: "root".into(), ppid: 1, tgid: 100, start_time_ns: 0 });
tree.insert_node(200, PidNode { ppid: 100, cmd: "bash".into() });
cache.insert_info(200, ProcInfo { cmd: "bash".into(), user: "root".into(), ppid: 100, tgid: 200, start_time_ns: 0 });
let chain = build_chain_string(&tree, &cache, 200);
assert_eq!(chain, "200|bash|root;100|sshd|root;1|init|root");