1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Re-Revert "Temporary revert "process.c: dead code when no SIGCHLD""

This re-reverts commit r64447.
The issue was machine side problem.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2018-08-21 13:39:24 +00:00
parent c8a34443c0
commit 682a661e1c
2 changed files with 17 additions and 7 deletions

View file

@ -981,6 +981,7 @@ rb_sigwait_fd_migrate(rb_vm_t *vm)
rb_native_mutex_unlock(&vm->waitpid_lock); rb_native_mutex_unlock(&vm->waitpid_lock);
} }
#if RUBY_SIGCHLD
static void static void
waitpid_notify(struct waitpid_state *w, rb_pid_t ret) waitpid_notify(struct waitpid_state *w, rb_pid_t ret)
{ {
@ -994,13 +995,7 @@ waitpid_notify(struct waitpid_state *w, rb_pid_t ret)
} }
} }
#ifdef _WIN32 /* for spawnvp result from mjit.c */
# define waitpid_sys(pid,status,options) \
(WaitForSingleObject((HANDLE)(pid), 0),\
GetExitCodeProcess((HANDLE)(pid), (LPDWORD)(status)))
#else
# define waitpid_sys(pid,status,options) do_waitpid((pid),(status),(options)) # define waitpid_sys(pid,status,options) do_waitpid((pid),(status),(options))
#endif
extern volatile unsigned int ruby_nocldwait; /* signal.c */ extern volatile unsigned int ruby_nocldwait; /* signal.c */
/* called by timer thread or thread which acquired sigwait_fd */ /* called by timer thread or thread which acquired sigwait_fd */
@ -1032,10 +1027,14 @@ waitpid_each(struct list_head *head)
} }
} }
} }
#else
# define ruby_nocldwait 0
#endif
void void
ruby_waitpid_all(rb_vm_t *vm) ruby_waitpid_all(rb_vm_t *vm)
{ {
#if RUBY_SIGCHLD
rb_native_mutex_lock(&vm->waitpid_lock); rb_native_mutex_lock(&vm->waitpid_lock);
waitpid_each(&vm->waiting_pids); waitpid_each(&vm->waiting_pids);
if (list_empty(&vm->waiting_pids)) { if (list_empty(&vm->waiting_pids)) {
@ -1047,6 +1046,7 @@ ruby_waitpid_all(rb_vm_t *vm)
; /* keep looping */ ; /* keep looping */
} }
rb_native_mutex_unlock(&vm->waitpid_lock); rb_native_mutex_unlock(&vm->waitpid_lock);
#endif
} }
static void static void
@ -4458,21 +4458,27 @@ rb_f_system(int argc, VALUE *argv)
execarg_obj = rb_execarg_new(argc, argv, TRUE, TRUE); execarg_obj = rb_execarg_new(argc, argv, TRUE, TRUE);
TypedData_Get_Struct(execarg_obj, struct rb_execarg, &exec_arg_data_type, eargp); TypedData_Get_Struct(execarg_obj, struct rb_execarg, &exec_arg_data_type, eargp);
#if RUBY_SIGCHLD
eargp->nocldwait_prev = ruby_nocldwait; eargp->nocldwait_prev = ruby_nocldwait;
ruby_nocldwait = 0; ruby_nocldwait = 0;
#endif
pid = rb_execarg_spawn(execarg_obj, NULL, 0); pid = rb_execarg_spawn(execarg_obj, NULL, 0);
#if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV) #if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV)
if (pid > 0) { if (pid > 0) {
int ret, status; int ret, status;
ret = rb_waitpid(pid, &status, 0); ret = rb_waitpid(pid, &status, 0);
if (ret == (rb_pid_t)-1) { if (ret == (rb_pid_t)-1) {
# if RUBY_SIGCHLD
ruby_nocldwait = eargp->nocldwait_prev; ruby_nocldwait = eargp->nocldwait_prev;
# endif
RB_GC_GUARD(execarg_obj); RB_GC_GUARD(execarg_obj);
rb_sys_fail("Another thread waited the process started by system()."); rb_sys_fail("Another thread waited the process started by system().");
} }
} }
#endif #endif
#if RUBY_SIGCHLD
ruby_nocldwait = eargp->nocldwait_prev; ruby_nocldwait = eargp->nocldwait_prev;
#endif
if (pid < 0) { if (pid < 0) {
if (eargp->exception) { if (eargp->exception) {
int err = errno; int err = errno;

View file

@ -531,7 +531,9 @@ static struct {
rb_atomic_t cnt[RUBY_NSIG]; rb_atomic_t cnt[RUBY_NSIG];
rb_atomic_t size; rb_atomic_t size;
} signal_buff; } signal_buff;
#if RUBY_SIGCHLD
volatile unsigned int ruby_nocldwait; volatile unsigned int ruby_nocldwait;
#endif
#ifdef __dietlibc__ #ifdef __dietlibc__
#define sighandler_t sh_t #define sighandler_t sh_t
@ -615,7 +617,8 @@ ruby_signal(int signum, sighandler_t handler)
#endif #endif
switch (signum) { switch (signum) {
case SIGCHLD: #if RUBY_SIGCHLD
case RUBY_SIGCHLD:
if (handler == SIG_IGN) { if (handler == SIG_IGN) {
ruby_nocldwait = 1; ruby_nocldwait = 1;
if (sigact.sa_flags & SA_SIGINFO) { if (sigact.sa_flags & SA_SIGINFO) {
@ -629,6 +632,7 @@ ruby_signal(int signum, sighandler_t handler)
ruby_nocldwait = 0; ruby_nocldwait = 0;
} }
break; break;
#endif
#if defined(SA_ONSTACK) && defined(USE_SIGALTSTACK) #if defined(SA_ONSTACK) && defined(USE_SIGALTSTACK)
case SIGSEGV: case SIGSEGV:
#ifdef SIGBUS #ifdef SIGBUS