Method: ProcessTree.child_pids_of
- Defined in:
- lib/clarity/process_tree.rb
.child_pids_of(ppid) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/clarity/process_tree.rb', line 11 def self.child_pids_of(ppid) out = `ps -opid,ppid | grep #{ppid.to_s}` ids = out.split("\n").map {|line| $1 if line =~ /^\s*([0-9]+)\s.*/ }.compact ids.delete(ppid.to_s) if ids.empty? ids else ids << ids.map {|id| child_pids_of(id) } end end |