Method: ChildProcess::AbstractProcess#poll_for_exit

Defined in:
lib/childprocess/abstract_process.rb

#poll_for_exit(timeout) ⇒ Object

Wait for the process to exit, raising a ChildProcess::TimeoutError if the timeout expires.



143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/childprocess/abstract_process.rb', line 143

def poll_for_exit(timeout)
  log "polling #{timeout} seconds for exit"

  end_time = Time.now + timeout
  until (ok = exited?) || Time.now > end_time
    sleep POLL_INTERVAL
  end

  unless ok
    raise TimeoutError, "process still alive after #{timeout} seconds"
  end
end