Sha256: 9f38711039d72e173ba6224570c266231a3bac54512f1a8184583cdbfa04a24a

Contents?: true

Size: 412 Bytes

Versions: 7

Compression:

Stored size: 412 Bytes

Contents

module Process
  
  ##
  # Check if process _pid_ is alive. Where _pid_
  # may be a pidfile path, or an integer.
  
  def self.alive? pid
    pid = pid_from_file(pid) if String === pid
    Process.kill 0, pid if Numeric === pid
  rescue Errno::ESRCH
  end
  
  ##
  # Get pid integer from pidfile at _path_.
  
  def self.pid_from_file path
    if File.exists? path
      File.read(path).to_i
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rext-0.7.0 lib/rext/process/helpers.rb
rext-0.6.2 lib/rext/process/helpers.rb
rext-0.6.1 lib/rext/process/helpers.rb
rext-0.6.0 lib/rext/process/helpers.rb
rext-0.5.0 lib/rext/process/helpers.rb
rext-0.4.1 lib/rext/process/helpers.rb
rext-0.4.0 lib/rext/process/helpers.rb