Module: Process

Defined in:
lib/process_exists/core_ext/process.rb

Overview

The Process module is a collection of methods used to manipulate processes.

Class Method Summary collapse

Class Method Details

.exists?(pid) ⇒ Boolean

Checks if a process exists

Parameters:

  • pid

    the process id

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
# File 'lib/process_exists/core_ext/process.rb', line 5

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