Module: Process

Defined in:
lib/rext/process/helpers.rb

Class Method Summary collapse

Class Method Details

.alive?(pid) ⇒ Boolean

Check if process pid is alive. Where pid may be a pidfile path, or an integer.

Returns:

  • (Boolean)


8
9
10
11
12
# File 'lib/rext/process/helpers.rb', line 8

def self.alive? pid
  pid = pid_from_file(pid) if String === pid
  Process.kill 0, pid if Numeric === pid
rescue Errno::ESRCH
end

.pid_from_file(path) ⇒ Object

Get pid integer from pidfile at path.



17
18
19
20
21
# File 'lib/rext/process/helpers.rb', line 17

def self.pid_from_file path
  if File.exists? path
    File.read(path).to_i
  end
end