pub fn find_by_cmd(tree: &impl TreeStore, target_cmd: &str) -> Vec<u32>Expand description
Find all PIDs whose cmd matches the given string.
use proc_tree::{DefaultTree, find_by_cmd, TreeStore, PidNode};
let tree = DefaultTree::new(100, 0);
tree.insert_node(1, PidNode { ppid: 0, cmd: "init".into() });
tree.insert_node(100, PidNode { ppid: 1, cmd: "sshd".into() });
tree.insert_node(200, PidNode { ppid: 1, cmd: "sshd".into() });
tree.insert_node(300, PidNode { ppid: 1, cmd: "bash".into() });
let mut sshds = find_by_cmd(&tree, "sshd");
sshds.sort();
assert_eq!(sshds, vec![100, 200]);
assert_eq!(find_by_cmd(&tree, "nginx"), Vec::<u32>::new());