diff options
author | Yusuke Endoh <[email protected]> | 2021-07-15 16:41:54 +0900 |
---|---|---|
committer | Yusuke Endoh <[email protected]> | 2021-07-15 16:46:08 +0900 |
commit | 645616c273aa9a328ca4ed3fceac8705e2e036cd (patch) | |
tree | 8cb84c6d98b5632280b9d1a3544d83bc0c9f1ab1 /process.c | |
parent | 8f62f12c35cf0bb3c6b48c1e59477d6b0da79067 (diff) |
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_.)
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -4293,8 +4293,10 @@ rb_fork_ruby(int *status) 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) 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) #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); \ } |