summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'process.c')
-rw-r--r--process.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/process.c b/process.c
index e093786600..216aba6750 100644
--- a/process.c
+++ b/process.c
@@ -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); \
}