Module: EM::PidPoller
- Defined in:
- lib/eventmachine/pid_poller.rb
Class Method Summary collapse
Class Method Details
.on_exit(pid, *a, &b) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/eventmachine/pid_poller.rb', line 3 def self.on_exit pid, *a, &b cb = EM::Callback *a, &b poller = EM.add_periodic_timer(1) do state = process_alive?(pid) unless state poller.cancel cb.call end end cb end |
.process_alive?(pid) ⇒ Boolean
15 16 17 18 19 20 |
# File 'lib/eventmachine/pid_poller.rb', line 15 def self.process_alive? pid Process.kill(0, pid) true rescue Errno::ESRCH false end |