зеркало из https://github.com/github/ruby.git
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_.)
This commit is contained in:
Родитель
8f62f12c35
Коммит
645616c273
1
io.c
1
io.c
|
@ -6871,7 +6871,6 @@ pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
|
|||
# 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);
|
||||
|
|
|
@ -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); \
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче