diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-08 00:02:27 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-08 00:02:27 +0000 |
commit | b93dc848835f93efc100cde2d3056512e7ddf557 (patch) | |
tree | 7e82c88368a5101d28ae9eade99e2b5831412ec8 /signal.c | |
parent | 4719a45483fe7716e81b6f22c2f8f6b41dfb8d58 (diff) | |
download | ruby-b93dc848835f93efc100cde2d3056512e7ddf557.tar.gz |
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
Diffstat (limited to 'signal.c')
-rw-r--r-- | signal.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -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; } |