class Sys::ProcTree::Tree

Public Class Methods

find(pid) click to toggle source
# File lib/sys/proctree/tree.rb, line 6
def self.find(pid)
  self.new(pid).pids
end
new(pid) click to toggle source
# File lib/sys/proctree/tree.rb, line 10
def initialize(pid)
  @pid = pid
end

Public Instance Methods

pids() click to toggle source
# File lib/sys/proctree/tree.rb, line 14
def pids
  process_status_list.exists?(@pid) ? with_children([@pid]) : []
end

Private Instance Methods

process_status_list() click to toggle source
# File lib/sys/proctree/tree.rb, line 27
def process_status_list
  @process_status_list ||= ::Sys::ProcTree::ProcessStatusList.new
end
with_children(pids) click to toggle source
# File lib/sys/proctree/tree.rb, line 20
def with_children(pids)
  child_pids = process_status_list.map do |proc|
    pids.include?(proc.ppid) ? proc.pid : nil
  end.compact
  child_pids.empty? ? pids : with_children(child_pids) + pids
end