### Home Classes Methods

### In Files

- common/src/rb/lib/selenium/webdriver/child_process.rb

### Parent

Object

### Namespace

- MODULE Selenium::WebDriver::ChildProcess::IronRubyProcess
- MODULE Selenium::WebDriver::ChildProcess::JRubyProcess
- MODULE Selenium::WebDriver::ChildProcess::WindowsProcess

### Methods

- ::new
- #assert_started
- #ensure_death
- #exit_value
- #kill
- #kill!
- #start
- #ugly_death?
- #wait
- #wait_nonblock

### Class/Module Index

Quicksearch

- Selenium
- Selenium::WebDriver
- Selenium::WebDriver::BridgeHelper
- Selenium::WebDriver::ChildProcess
- Selenium::WebDriver::ChildProcess::IronRubyProcess
- Selenium::WebDriver::ChildProcess::JRubyProcess
- Selenium::WebDriver::ChildProcess::WindowsProcess
- Selenium::WebDriver::Chrome
- Selenium::WebDriver::Chrome::Bridge
- Selenium::WebDriver::Chrome::CommandExecutor
- Selenium::WebDriver::Chrome::Launcher
- Selenium::WebDriver::Chrome::Launcher::MacOSXLauncher
- Selenium::WebDriver::Chrome::Launcher::UnixLauncher
- Selenium::WebDriver::Chrome::Launcher::WindowsLauncher
- Selenium::WebDriver::Driver
- Selenium::WebDriver::DriverExtensions
- Selenium::WebDriver::DriverExtensions::TakesScreenshot
- Selenium::WebDriver::Element
- Selenium::WebDriver::Error
- Selenium::WebDriver::Error::ElementNotDisplayedError
- Selenium::WebDriver::Error::ElementNotEnabledError
- Selenium::WebDriver::Error::ElementNotSelectableError
- Selenium::WebDriver::Error::ExpectedError
- Selenium::WebDriver::Error::IndexOutOfBoundsError
- Selenium::WebDriver::Error::InvalidCookieDomainError
- Selenium::WebDriver::Error::NoCollectionError
- Selenium::WebDriver::Error::NoScriptResultError
- Selenium::WebDriver::Error::NoStringError
- Selenium::WebDriver::Error::NoStringLengthError
- Selenium::WebDriver::Error::NoStringWrapperError
- Selenium::WebDriver::Error::NoSuchCollectionError
- Selenium::WebDriver::Error::NoSuchDocumentError
- Selenium::WebDriver::Error::NoSuchDriverError
- Selenium::WebDriver::Error::NoSuchElementError
- Selenium::WebDriver::Error::NoSuchFrameError
- Selenium::WebDriver::Error::NoSuchWindowError
- Selenium::WebDriver::Error::NullPointerError
- Selenium::WebDriver::Error::ObsoleteElementError
- Selenium::WebDriver::Error::ServerError
- Selenium::WebDriver::Error::TimeOutError
- Selenium::WebDriver::Error::UnableToSetCookieError
- Selenium::WebDriver::Error::UnexpectedJavascriptError
- Selenium::WebDriver::Error::UnhandledError
- Selenium::WebDriver::Error::UnknownCommandError
- Selenium::WebDriver::Error::UnknownScriptResultError
- Selenium::WebDriver::Error::UnsupportedOperationError
- Selenium::WebDriver::Error::WebDriverError
- Selenium::WebDriver::FileReaper
- Selenium::WebDriver::Find
- Selenium::WebDriver::Firefox
- Selenium::WebDriver::Firefox::Binary
- Selenium::WebDriver::Firefox::Bridge
- Selenium::WebDriver::Firefox::Launcher
- Selenium::WebDriver::Firefox::Profile
- Selenium::WebDriver::Firefox::ProfilesIni
- Selenium::WebDriver::Firefox::Util
- Selenium::WebDriver::IE
- Selenium::WebDriver::IE::Bridge
- Selenium::WebDriver::IE::Kernel32
- Selenium::WebDriver::IE::Lib
- Selenium::WebDriver::IE::Util
- Selenium::WebDriver::Keys
- Selenium::WebDriver::Navigation
- Selenium::WebDriver::Options
- Selenium::WebDriver::Platform
- Selenium::WebDriver::Remote
- Selenium::WebDriver::Remote::Bridge
- Selenium::WebDriver::Remote::Capabilities
- Selenium::WebDriver::Remote::Http
- Selenium::WebDriver::Remote::Http::Common
- Selenium::WebDriver::Remote::Http::Curb
- Selenium::WebDriver::Remote::Http::Default
- Selenium::WebDriver::Remote::Response
- Selenium::WebDriver::TargetLocator
- Selenium::WebDriver::Timeouts
- Dir
- SocketError
- String

No matching classes.

# Selenium::WebDriver::ChildProcess

Cross platform child process launcher

@private

### Attributes

pid[R]

### Public Class Methods

new(*args) click to toggle source

    # File common/src/rb/lib/selenium/webdriver/child_process.rb, line 13
    def initialize(*args)
      @args = args

      if Platform.jruby?
        extend JRubyProcess
      elsif Platform.ironruby?
        extend IronRubyProcess
      elsif Platform.os == :windows
        extend WindowsProcess
      end
    end

### Public Instance Methods

assert_started() click to toggle source

    # File common/src/rb/lib/selenium/webdriver/child_process.rb, line 114
    def assert_started
      raise Error::WebDriverError, "process not started" unless @pid
    end

ensure_death() click to toggle source

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

exit_value() click to toggle source

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

kill() click to toggle source

    # File common/src/rb/lib/selenium/webdriver/child_process.rb, line 104
    def kill
      assert_started
      Process.kill('TERM', @pid)
    end

kill!() click to toggle source

    # File common/src/rb/lib/selenium/webdriver/child_process.rb, line 109
    def kill!
      assert_started
      Process.kill('KILL', @pid)
    end

start() click to toggle source

    # 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

ugly_death?() click to toggle source

    # File common/src/rb/lib/selenium/webdriver/child_process.rb, line 25
    def ugly_death?
      code = exit_value
      code && code != 0
    end

wait() click to toggle source

    # File common/src/rb/lib/selenium/webdriver/child_process.rb, line 97
    def wait
      assert_started
      Process.waitpid2 @pid
    rescue Errno::ECHILD
      nil
    end

wait_nonblock(timeout) click to toggle source

    # 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.