1
2
3
4
5
6
7
8
9
10
11
12
use procfs::process;

/// Check, whether a specific process is exists or not
pub fn process_exists(pid: u32) -> bool {
    match pid.try_into() {
        Err(_) => false,
        Ok(pid) => match process::Process::new(pid) {
            Ok(process) => process.is_alive(),
            Err(_) => false,
        },
    }
}