pub fn get_process(pid: u32) -> SysprimsResult<ProcessInfo>Expand description
Get information for a single process.
§Errors
Returns NotFound if the process does not exist.
Returns PermissionDenied if the process cannot be read.
§Liveness and zombies (cross-platform note)
This function reports a process’s record, not a normalized liveness answer,
and the two platforms diverge for an exited-but-unreaped child. On Linux the
kernel keeps the PID in the process table with state
ProcessState::Zombie until the parent reaps it, so get_process returns
Ok(_) with state == Zombie. On macOS the same PID typically becomes
unreadable almost immediately, so get_process returns Err(NotFound).
Treating Ok(_) as “alive” is therefore not portable. When you need “is this
process actually still running?” use is_live (returns false for zombies
on every platform); for “is every trace of it gone?” use is_fully_gone; to
block until exit, use wait_pid. If you keep using get_process, inspect
ProcessInfo::state and treat ProcessState::Zombie as not-running.
§Examples
// Replaces: ps -p <pid> -o ... plus parsing
let self_info = sysprims_proc::get_process(std::process::id()).unwrap();
println!("Current process: {}", self_info.name);