Skip to content

Commit

Permalink
[rb] Don't crash when ChildProcess is already killed
Browse files Browse the repository at this point in the history
Fixes #14032
  • Loading branch information
p0deje committed May 28, 2024
1 parent 0d6ce4f commit 1be430f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rb/lib/selenium/webdriver/common/child_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def exited?
return false unless @pid

WebDriver.logger.debug("Checking if #{@pid} is exited:", id: :process)
_, @status = Process.waitpid2(@pid, Process::WNOHANG | Process::WUNTRACED) if @status.nil?
_, @status = waitpid2(@pid, Process::WNOHANG | Process::WUNTRACED) if @status.nil?
return false if @status.nil?

exit_code = @status.exitstatus || @status.termsig
Expand All @@ -105,7 +105,7 @@ def poll_for_exit(timeout)
def wait
return if exited?

_, @status = Process.waitpid2(@pid)
_, @status = waitpid2(@pid)
end

private
Expand All @@ -119,6 +119,12 @@ def kill(pid)
rescue Errno::ECHILD, Errno::ESRCH
# already dead
end

def waitpid2(pid, flags = 0)
Process.waitpid2(pid, flags)
rescue Errno::ECHILD
# already dead
end
end # ChildProcess
end # WebDriver
end # Selenium

0 comments on commit 1be430f

Please sign in to comment.