From b93dc848835f93efc100cde2d3056512e7ddf557 Mon Sep 17 00:00:00 2001 From: normal Date: Sun, 8 Jul 2018 00:02:27 +0000 Subject: signal.c: preserve trap(:CHLD, "IGNORE") behavior with SIGCHLD We need to preserve "IGNORE" behavior from Ruby 2.5 and earlier. We can't rely on SA_NOCLDWAIT any more, since we always need system() and MJIT to work; so we fake that behavior using dedicated reaper (currently in timer-thread). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- signal.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'signal.c') diff --git a/signal.c b/signal.c index e9f0708510..6393273adf 100644 --- a/signal.c +++ b/signal.c @@ -531,6 +531,7 @@ static struct { rb_atomic_t cnt[RUBY_NSIG]; rb_atomic_t size; } signal_buff; +volatile unsigned int ruby_nocldwait; #ifdef __dietlibc__ #define sighandler_t sh_t @@ -614,12 +615,20 @@ ruby_signal(int signum, sighandler_t handler) #endif switch (signum) { -#ifdef SA_NOCLDWAIT case SIGCHLD: - if (handler == SIG_IGN) - sigact.sa_flags |= SA_NOCLDWAIT; + if (handler == SIG_IGN) { + ruby_nocldwait = 1; + if (sigact.sa_flags & SA_SIGINFO) { + sigact.sa_sigaction = (ruby_sigaction_t*)sighandler; + } + else { + sigact.sa_handler = sighandler; + } + } + else { + ruby_nocldwait = 0; + } break; -#endif #if defined(SA_ONSTACK) && defined(USE_SIGALTSTACK) case SIGSEGV: #ifdef SIGBUS @@ -1183,9 +1192,6 @@ trap_handler(VALUE *cmd, int sig) VALUE command; if (NIL_P(*cmd)) { - if (sig == RUBY_SIGCHLD) { - goto sig_dfl; - } func = SIG_IGN; } else { @@ -1216,9 +1222,6 @@ trap_handler(VALUE *cmd, int sig) case 7: if (memcmp(cptr, "SIG_IGN", 7) == 0) { sig_ign: - if (sig == RUBY_SIGCHLD) { - goto sig_dfl; - } func = SIG_IGN; *cmd = Qtrue; } -- cgit v1.2.3