Skip to content

Instantly share code, notes, and snippets.

@skolf
Created June 19, 2014 22:28
Show Gist options
  • Select an option

  • Save skolf/f70bce603d5241fc707e to your computer and use it in GitHub Desktop.

Select an option

Save skolf/f70bce603d5241fc707e to your computer and use it in GitHub Desktop.
An extension to the Ruby Process module for checking if a given process is running.
# usage: Process.alive? 1
# > true
module Process
class << self
def alive?(pid)
return false if pid.nil?
begin
Process.kill(0, pid.to_i)
status = true
rescue Errno::ESRCH
status = false
end
return status
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment