Class: Children
- Inherits:
-
Array
- Object
- Array
- Children
- Defined in:
- lib/forkme/children.rb
Instance Method Summary collapse
Instance Method Details
#active ⇒ Object
10 11 12 |
# File 'lib/forkme/children.rb', line 10 def active() self.map{|c| c.active? ? c : nil}.compact end |
#by_fd(fd) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/forkme/children.rb', line 18 def by_fd(fd) self.each do |c| return c if c.from == fd end nil end |
#cleanup ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/forkme/children.rb', line 25 def cleanup() new = Children.new self.each do |c| begin if Process.waitpid(c.pid, Process::WNOHANG) then #Forkme.logger.debug "p: catch exited child #{c.pid}" c.exit else new << c end rescue Errno::ECHILD end end self.replace new end |
#fds ⇒ Object
2 3 4 |
# File 'lib/forkme/children.rb', line 2 def fds() self.map{|c| c.active? ? c.from : nil}.compact.flatten end |
#idle ⇒ Object
14 15 16 |
# File 'lib/forkme/children.rb', line 14 def idle() self.map{|c| c.idle? ? c : nil}.compact end |
#pids ⇒ Object
6 7 8 |
# File 'lib/forkme/children.rb', line 6 def pids() self.map{|c| c.pid} end |