Object
Cross platform child process launcher
@private
# File common/src/rb/lib/selenium/webdriver/child_process.rb, line 114 def assert_started raise Error::WebDriverError, "process not started" unless @pid end
Tries increasingly harsher methods to make the process die within a reasonable time
# File common/src/rb/lib/selenium/webdriver/child_process.rb, line 56 def ensure_death begin $stderr.puts "wait_nonblock(5) -> #{self}" if $DEBUG return wait_nonblock(5) rescue Error::TimeOutError # try next end $stderr.puts "TERM -> #{self}" if $DEBUG kill begin $stderr.puts "wait_nonblock(5) -> #{self}" if $DEBUG return wait_nonblock(5) rescue Error::TimeOutError # try next end $stderr.puts "KILL -> #{self}" if $DEBUG kill! $stderr.puts "wait_nonblock(5) -> #{self}" if $DEBUG wait_nonblock(5) rescue Errno::ECHILD # great! true end
Returns the exit value of the process, or nil if it’s still alive.
# File common/src/rb/lib/selenium/webdriver/child_process.rb, line 34 def exit_value pid, status = Process.waitpid2(@pid, Process::WNOHANG) status.exitstatus if pid end
# File common/src/rb/lib/selenium/webdriver/child_process.rb, line 104 def kill assert_started Process.kill('TERM', @pid) end
# File common/src/rb/lib/selenium/webdriver/child_process.rb, line 109 def kill! assert_started Process.kill('KILL', @pid) end
# File common/src/rb/lib/selenium/webdriver/child_process.rb, line 39 def start @pid = fork do unless $DEBUG [STDOUT, STDERR].each { |io| io.reopen("/dev/null") } end exec(*@args) end self end
# File common/src/rb/lib/selenium/webdriver/child_process.rb, line 25 def ugly_death? code = exit_value code && code != 0 end
# File common/src/rb/lib/selenium/webdriver/child_process.rb, line 97 def wait assert_started Process.waitpid2 @pid rescue Errno::ECHILD nil end
# File common/src/rb/lib/selenium/webdriver/child_process.rb, line 84 def wait_nonblock(timeout) end_time = Time.now + timeout until Time.now > end_time || exited = exit_value sleep 0.1 end unless exited raise Error::TimeOutError, "process still alive after #{timeout} seconds" end exited end
Generated with the Darkfish Rdoc Generator 2.