Skip to content

Instantly share code, notes, and snippets.

@volh
Created December 1, 2010 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volh/723528 to your computer and use it in GitHub Desktop.
Save volh/723528 to your computer and use it in GitHub Desktop.
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