Class: ArcadiaUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/a-core.rb

Class Method Summary collapse

Class Method Details

.unix_child_pids(_ppid) ⇒ Object



3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
# File 'lib/a-core.rb', line 3716

def ArcadiaUtils.unix_child_pids(_ppid)
  ret = Array.new
  readed = ''
  open("|ps -o pid,ppid ax | grep #{_ppid}", "r"){|f|  readed = f.read  }
  apids = readed.split
  apids.each_with_index do |v,i|
    ret << v if i % 2 == 0 && v != _ppid.to_s
  end
  subpids = Array.new
  ret.each{|ccp|
    subpids.concat(unix_child_pids(ccp))
  }
  ret.concat(subpids)
end