ruby-changes:66791
From: Yusuke <ko1@a...>
Date: Thu, 15 Jul 2021 16:46:33 +0900 (JST)
Subject: [ruby-changes:66791] 645616c273 (master): process.c: Call rb_thread_atfork in rb_fork_ruby
https://git.ruby-lang.org/ruby.git/commit/?id=645616c273 From 645616c273aa9a328ca4ed3fceac8705e2e036cd Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Thu, 15 Jul 2021 16:41:54 +0900 Subject: process.c: Call rb_thread_atfork in rb_fork_ruby All occurrences of rb_fork_ruby are followed by a call rb_thread_fork in the created child process. This is refactoring and a potential preparation for [Feature #17795]. (rb_fork_ruby may be wrapped by Process._fork_.) --- io.c | 1 - process.c | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/io.c b/io.c index 1fafff2..8b7e137 100644 --- a/io.c +++ b/io.c @@ -6871,7 +6871,6 @@ pipe_open(VALUE execarg_obj, const char *modestr, int fmode, https://github.com/ruby/ruby/blob/trunk/io.c#L6871 # if defined(HAVE_WORKING_FORK) pid = rb_fork_ruby(&status); if (pid == 0) { /* child */ - rb_thread_atfork(); popen_redirect(&arg); rb_io_synchronized(RFILE(orig_stdout)->fptr); rb_io_synchronized(RFILE(orig_stderr)->fptr); diff --git a/process.c b/process.c index e093786..216aba6 100644 --- a/process.c +++ b/process.c @@ -4293,8 +4293,10 @@ rb_fork_ruby(int *status) https://github.com/ruby/ruby/blob/trunk/process.c#L4293 after_fork_ruby(); disable_child_handler_fork_parent(&old); /* yes, bad name */ if (mjit_enabled && pid > 0) mjit_resume(); /* child (pid == 0) is cared by rb_thread_atfork */ - if (pid >= 0) /* fork succeed */ + if (pid >= 0) { /* fork succeed */ + if (pid == 0) rb_thread_atfork(); return pid; + } /* fork failed */ if (handle_fork_error(err, status, NULL, &try_gc)) return -1; @@ -4336,7 +4338,6 @@ rb_f_fork(VALUE obj) https://github.com/ruby/ruby/blob/trunk/process.c#L4338 switch (pid = rb_fork_ruby(NULL)) { case 0: - rb_thread_atfork(); if (rb_block_given_p()) { int status; rb_protect(rb_yield, Qundef, &status); @@ -7012,7 +7013,7 @@ rb_daemon(int nochdir, int noclose) https://github.com/ruby/ruby/blob/trunk/process.c#L7013 #define fork_daemon() \ switch (rb_fork_ruby(NULL)) { \ case -1: return -1; \ - case 0: rb_thread_atfork(); break; \ + case 0: break; \ default: _exit(EXIT_SUCCESS); \ } -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/