#[non_exhaustive]pub enum ProcessState {
Alive,
Exited,
Unknown,
}Expand description
What the OS can establish about a PID.
Unknown is its own state because the two useful answers need proof in
opposite directions. Retiring a process’s work needs proof it exited;
treating it as still serving needs proof it runs. A denied or failed query
proves neither, and a caller that folds it into either side eventually acts
on a guess: waiting forever for a process that is gone, or starting a
second owner next to one that is not.
Alive is about a PID, not a program: a PID is reused once its process is
gone, on Unix and on Windows alike, so a PID that reads as alive may belong
to an unrelated process by now. Before treating it as the daemon you
started, confirm through its endpoint (connect and check the peer). To
follow one process rather than a PID, keep a ProcessHandle.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Alive
A process with this PID exists and has not exited. It may be a different process from the one that first had the PID.
Exited
The process exited, or no process has this PID any more.
Unknown
The OS did not say, for example because access to the process was denied. Neither alive nor exited can be assumed.