Skip to content

[rb] Fix child process terminate method when a process is already terminated #15789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8c317d8
[build] allow tests tagged exclusive-if-local to run on rbe
titusfortner Mar 22, 2025
bb29c66
merge trunk
aguspe Apr 2, 2025
5b6a0ce
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Apr 22, 2025
c9cb77c
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Apr 30, 2025
ac9a80e
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe May 18, 2025
aef922a
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe May 24, 2025
09fad56
Add rescue and test for child_process terminate method
aguspe May 24, 2025
c4b9a69
Merge branch 'trunk' into bugfix/rb_fix_child_process_error
aguspe May 24, 2025
3c51e0b
Add rescue for kill method
aguspe May 24, 2025
7f7b038
Merge remote-tracking branch 'origin/bugfix/rb_fix_child_process_erro…
aguspe May 24, 2025
2d4107a
guard against windows
aguspe May 24, 2025
b86b313
guard against windows
aguspe May 26, 2025
752fb78
move child process test
aguspe May 29, 2025
a52013a
Merge branch 'trunk' into bugfix/rb_fix_child_process_error
aguspe May 29, 2025
d4fdb8c
remove guard
aguspe May 29, 2025
6064435
Merge branch 'trunk' into bugfix/rb_fix_child_process_error
aguspe May 29, 2025
869adb8
Update test
aguspe May 30, 2025
3137265
Merge remote-tracking branch 'origin/bugfix/rb_fix_child_process_erro…
aguspe May 30, 2025
62e312c
Merge branch 'trunk' into bugfix/rb_fix_child_process_error
aguspe May 30, 2025
71264c9
add windows guard
aguspe May 30, 2025
a605a07
Merge remote-tracking branch 'origin/bugfix/rb_fix_child_process_erro…
aguspe May 30, 2025
0ac3395
add windows guard
aguspe May 30, 2025
1aa51ea
Merge branch 'trunk' into bugfix/rb_fix_child_process_error
aguspe May 30, 2025
b620c61
Merge branch 'trunk' into bugfix/rb_fix_child_process_error
aguspe May 31, 2025
5cfc403
Merge branch 'trunk' into bugfix/rb_fix_child_process_error
aguspe May 31, 2025
80de7db
Merge branch 'trunk' into bugfix/rb_fix_child_process_error
aguspe Jun 7, 2025
8220e8e
Merge branch 'trunk' into bugfix/rb_fix_child_process_error
aguspe Jun 9, 2025
3f19047
Merge branch 'trunk' into bugfix/rb_fix_child_process_error
aguspe Jun 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rb/lib/selenium/webdriver/common/child_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,14 @@ def terminate_and_wait_else_kill(timeout)

def terminate(pid)
Process.kill(SIGTERM, pid)
rescue Errno::ECHILD, Errno::ESRCH
# Process does not exist, nothing to terminate
end

def kill(pid)
Process.kill(SIGKILL, pid)
rescue Errno::ECHILD, Errno::ESRCH
# Process does not exist, nothing to kill
end

def waitpid2(pid, flags = 0)
Expand Down
54 changes: 54 additions & 0 deletions rb/spec/unit/selenium/webdriver/common/child_process_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# frozen_string_literal: true

# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

require File.expand_path('../spec_helper', __dir__)

module Selenium
module WebDriver
describe ChildProcess do
unless Selenium::WebDriver::Platform.windows?
it 'does not raise an error when terminating a non-existent process' do
process = described_class.new('sleep', '5')
process.start

pid = process.instance_variable_get(:@pid)
Process.kill('KILL', pid)
Process.wait(pid)

expect {
process.send(:terminate, pid)
}.not_to raise_error
end

it 'does not raise an error when killing a non-existent process' do
process = described_class.new('sleep', '5')
process.start

pid = process.instance_variable_get(:@pid)
Process.kill('KILL', pid)
Process.wait(pid)

expect {
process.send(:kill, pid)
}.not_to raise_error
end
end
end
end
end