Is there some way to check if an arbitrary PID is running or alive on the system, using Node.js? Assume that the Node.js script has the appropriate permissions to read
You can call process.kill(pid, 0) and wrap it up in a try/catch.
http://nodejs.org/api/process.html#process_process_kill_pid_signal -
"Will throw an error if target does not exist, and as a special case, a signal of 0 can be used to test for the existence of a process."
Example:
function pidIsRunning(pid) {
try {
process.kill(pid, 0);
return true;
} catch(e) {
return false;
}
}