There's no need to enumerate every single process to do this.
On *nix, you could check if the directory /proc/<pid> exists. If so, the process is alive.
On Windows, you could try opening a handle. If the handle doesn't open, consider the process as dead. If the handle does open, check if it has an exit code. If not, the process is alive.
There's no need to enumerate every single process to do this. On *nix, you could check if the directory
/proc/<pid>
exists. If so, the process is alive. On Windows, you could try opening a handle. If the handle doesn't open, consider the process as dead. If the handle does open, check if it has an exit code. If not, the process is alive.