Class: ArcadiaUtils

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

Class Method Summary collapse

Class Method Details

.exec(_cmd_ = nil) ⇒ Object



4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
# File 'lib/a-core.rb', line 4608

def ArcadiaUtils.exec(_cmd_=nil)
  return nil if _cmd_.nil?
  to_ret = ''
  begin
    open("|#{_cmd_}", "r"){|f| 
      #to_ret = f.readlines
      to_ret = f.read
    }
  rescue RuntimeError => e
    Arcadia.runtime_error(e)
  end
  to_ret
end

.unix_child_pids(_ppid) ⇒ Object



4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
# File 'lib/a-core.rb', line 4593

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