Class: WaitPid
- Inherits:
-
Object
- Object
- WaitPid
- Defined in:
- lib/wait_pid.rb
Class Method Summary collapse
Class Method Details
.wait_nonchild_pid(pid, test = false) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/wait_pid.rb', line 4 def self.wait_nonchild_pid(pid, test = false) # initial test count = 0 begin loop { Process.kill( 0, pid); count += 1; sleep 0.01} rescue Errno::ESRCH if count == 0 if test return "non existing" else puts "warning: pid not found #{pid}" if $VERBOSE end else # normal end end end |
.wait_nonchild_pids(*pids) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/wait_pid.rb', line 23 def self.wait_nonchild_pids *pids require 'thwait' all = [] pids.each{|pid| all << Thread.new(pid) {|pid| WaitPid.wait_nonchild_pid pid } } ThreadsWait.all_waits *all end |