Method: LinuxStat::ProcessInfo.gid

Defined in:
lib/linux_stat/process_info.rb

.gid(pid = $$) ⇒ Object

gid(pid = $$)

returns the GIDs of the process as an Hash containing the following data:

:real, :effective, :saved_set, :filesystem_uid

If the info isn’t available or the argument passed doesn’t exist as a process ID, it will return an empty Hash.



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/linux_stat/process_info.rb', line 450

def gid(pid = $$)
  file = "/proc/#{pid}/status".freeze
  return nil unless File.readable?(file)

  data = IO.foreach(file.freeze).find { |x|
    x[/Gid.*\d*/]
  }.split.drop(1)

  {
    real: data[0].to_i,
    effective: data[1].to_i,
    saved_set: data[2].to_i,
    filesystem_uid: data[3].to_i
  }
end