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 { 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: "sshd".into(), user: "root".into(), tgid: 200, start_time_ns: 0 });
store.insert_process(300, ProcessInfo { ppid: 1, cmd: "bash".into(), user: "root".into(), tgid: 300, start_time_ns: 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());