wilsonsilva/process_exists

View on GitHub
lib/process_exists/core_ext/process.rb

Summary

Maintainability
A
0 mins
Test Coverage
# The Process module is a collection of methods used to manipulate processes.
module Process
  # Checks if a process exists
  # @param pid the process id
  def self.exists?(pid)
    Process.kill(0, pid.to_i)
    true
  rescue Errno::ESRCH # No such process
    false
  rescue Errno::EPERM # The process exists, but you dont have permission to send the signal to it.
    true
  end
end