Check if a certain process is running
You can use sysinfo crate, or particularly processes_by_name
You can get iterator to processes containing the name using the function
fn processes_by_name<'a>(&'a self, name: &'a str) -> Box<dyn Iterator<Item = &'a Process> + 'a>
You can use it like this
use sysinfo::{ProcessExt, System, SystemExt};
let s = System::new_all();
for process in s.processes_by_name("htop") {
//check here if this is your process
}
UPDATE: New version (0.23.0) also contains processes_by_exact_name
It returns an iterator to processes with the exact given name You can use it like this
use sysinfo::{ProcessExt, System, SystemExt};
let s = System::new_all();
for process in s.processes_by_exact_name("htop") {
//Your code goes here
}