Skip to content

Allow concurrent use of system(), IO.popen and Process.spawn in ractors #13806

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions process.c
Original file line number Diff line number Diff line change
Expand Up @@ -4010,6 +4010,7 @@ retry_fork_async_signal_safe(struct rb_process_status *status, int *ep,

while (1) {
prefork();
rb_thread_acquire_fork_lock();
disable_child_handler_before_fork(&old);
#ifdef HAVE_WORKING_VFORK
if (!has_privilege())
Expand All @@ -4036,6 +4037,7 @@ retry_fork_async_signal_safe(struct rb_process_status *status, int *ep,
}
err = errno;
disable_child_handler_fork_parent(&old);
rb_thread_release_fork_lock();
if (0 < pid) /* fork succeed, parent process */
return pid;
/* fork failed */
Expand Down
18 changes: 18 additions & 0 deletions test/ruby/test_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2852,4 +2852,22 @@ def test_handle_interrupt_with_fork
rescue RuntimeError
# Ignore.
end if defined?(fork)

def test_concurrent_kernel_system_with_ractors_does_not_crash
omit "system('ls') is not supported" if windows?
assert_ractor <<-RUBY
rs = []
100.times do
rs << Ractor.new do
# system uses fork() internally, so does IO.popen and Process.spawn.
system("ls > /dev/null")
end
end

while rs.any?
r, _obj = Ractor.select(*rs)
rs.delete(r)
end
RUBY
end
end
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy