Created
December 1, 2010 14:14
-
-
Save volh/723528 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module God | |
module System | |
class Process | |
# Return true if this process is running, false otherwise | |
def exists? | |
!!::Process.kill(0, @pid) rescue false | |
end | |
end | |
end | |
# O'RLY? | |
# But it will return false for root processes!11 | |
def Process.alive?(pid) | |
Process.kill(0, pid) | |
rescue Errno::ESRCH | |
false | |
rescue Errno::EPERM | |
true | |
end | |
# Please, oh please be explicit with your exception handling. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment