Class: Facter::Util::Linux::Proc

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/util/linux/proc.rb

Class Method Summary collapse

Class Method Details

.getenv_for_pid(pid, field) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/facter/util/linux/proc.rb', line 8

def getenv_for_pid(pid, field)
  path = "/proc/#{pid}/environ"
  lines = Facter::Util::FileHelper.safe_readlines(path, [], "\0", chomp: true)
  lines.each do |line|
    key, value = line.split('=', 2)
    return value if key == field
  end
  nil
end