lib/wait_pid.rb in wait_pid-0.0.2 vs lib/wait_pid.rb in wait_pid-0.1.0
- old
+ new
@@ -1,9 +1,9 @@
class WaitPid
- def self.wait_pid(pid, test = false)
+ 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
@@ -16,8 +16,17 @@
else
# normal
end
end
+ end
+
+ 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
end
\ No newline at end of file