Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit f3f0593

Browse files
committed
Detach bisect process to avoid making zombie process
If we do not `waitpid` or `detach` the bisect process become a zombie process. As mentionned in waitpid doc: > As long as a zombie is not removed from the system via a wait, it will consume a slot in the kernel process table, and if this table fills, it will not be possible to create further processes. `detach` is a good idea. From the Ruby doc: > Some operating systems retain the status of terminated child processes until the parent collects that status (normally using some variant of wait()). If the parent never collects this status, the child stays around as a zombie process. Process::detach prevents this by setting up a separate Ruby thread whose sole job is to reap the status of the process pid when it terminates. Use detach only when you do not intend to explicitly wait for the child to terminate. Related: - #2669 - https://andrykonchin.github.io/rails/2019/12/25/deadlock-in-rspec.html
1 parent e7c5d03 commit f3f0593

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/rspec/core/bisect/fork_runner.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,12 @@ def initialize(runner, channel)
9191
end
9292

9393
def dispatch_specs(run_descriptor)
94-
fork { run_specs(run_descriptor) }
94+
pid = fork { run_specs(run_descriptor) }
9595
# We don't use Process.waitpid here as it was causing bisects to
96-
# block due to the file descriptor limit on OSX / Linux.
96+
# block due to the file descriptor limit on OSX / Linux. We need
97+
# to detach the process to avoid having zombie process and consume
98+
# slot in the kernel process table.
99+
Process.detach(pid)
97100
end
98101

99102
private

0 commit comments

Comments
 (0)