module Vigilem::X11::System

Public Instance Methods

environ_file(pid='self') click to toggle source

@param [Intger] pid @return [File]

# File lib/vigilem/x11/system.rb, line 14
def environ_file(pid='self')
  file_path = "#{File::SEPARATOR}#{File.join('proc', pid.to_s, 'environ')}"
  if test ?e, file_path
    @environ = File.open(file_path)
  end
end
ppid_of(pid) click to toggle source

gets the @param [Integer] pid @return [Integer || NilClass]

# File lib/vigilem/x11/system.rb, line 7
def ppid_of(pid)
  to_i!(`ps -p #{pid} -o ppid= 2>&1`.strip)
end
to_i!(str) click to toggle source

like to_i but returns nil if not convertable @todo move to support/core_ext @param [String] str @return [Integer || NilClass]

# File lib/vigilem/x11/system.rb, line 25
def to_i!(str)
  if str =~ /^\s*(0+|(0*\.0+))\s*$/
    0
  else
    [str.to_i].find {|i| i != 0 }
  end
end