If there is more than one way, please list them. I only know of one, but I\'m wondering if there is a cleaner, in-Ruby way.
A *nix
-only approach would be to shell-out to ps
and check if a \n
(new line) delimiter exists in the returned string.
Example IRB Output
1.9.3p448 :067 > `ps -p 56718`
" PID TTY TIME CMD\n56718 ttys007 0:03.38 zeus slave: default_bundle \n"
Packaged as a Method
def process?(pid)
!!`ps -p #{pid.to_i}`["\n"]
end