pub fn find_by_cmd(store: &impl ProcessStore, target_cmd: &str) -> Vec<u32>Expand description
Find all PIDs whose cmd matches the given string.
use proc_tree::{DefaultStore, find_by_cmd, 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("sshd".into(), "sshd".into(), "root".into(), 1, 200, 0));
store.insert_process(300, ProcessInfo::new("bash".into(), "bash".into(), "root".into(), 1, 300, 0));
let mut sshds = find_by_cmd(&store, "sshd");
sshds.sort();
assert_eq!(sshds, vec![100, 200]);
assert_eq!(find_by_cmd(&store, "nginx"), Vec::<u32>::new());