pub fn build_chain_string(store: &impl ProcessStore, 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::{DefaultStore, build_chain_string, ProcessStore, ProcessInfo};
let store = DefaultStore::new(0);
store.insert_process(1, ProcessInfo::new("init".into(), "init".into(), "root".into(), 0, 1, 0));
store.insert_process(100, ProcessInfo::new("sshd".into(), "sshd".into(), "root".into(), 1, 100, 0));
store.insert_process(200, ProcessInfo::new("bash".into(), "bash".into(), "root".into(), 100, 200, 0));
let chain = build_chain_string(&store, 200);
// Returns JSON array: [{"pid":200,"comm":"bash","cmd":"bash","user":"root"}, ...]
assert!(chain.contains("\"comm\":\"bash\""));