summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-10-09 23:13:59 +0900
committerYusuke Endoh <mame@ruby-lang.org>2019-10-09 23:22:15 +0900
commit891cbd66a411725d7300a28b1a95619c2902f0eb (patch)
tree58d4c2749523b7c1bc083d8686e6ce5cc02e5355 /error.c
parentdd477df411691803fc5a83c7daa64faac112a0e4 (diff)
downloadruby-891cbd66a411725d7300a28b1a95619c2902f0eb.tar.gz
signal.c: save the original sighandlers for fatal signals
On Android, a signal handler that is not SIG_DFL is set by default for SIGSEGV. Ruby's install_sighandler inserts Ruby's handler only when the signal has no handler, so it does not insert Ruby's SEGV report handler, which caused some test failures. This changeset forces to install Ruby's handler for some fatal signals (sigbus, sigsegv, and sigill). They keep the original handlers, and call them when the interpreter receives the signals.
Diffstat (limited to 'error.c')
-rw-r--r--error.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/error.c b/error.c
index 56ea9ae084..f8d2545fa6 100644
--- a/error.c
+++ b/error.c
@@ -599,7 +599,7 @@ rb_bug(const char *fmt, ...)
}
void
-rb_bug_for_fatal_signal(const void *ctx, const char *fmt, ...)
+rb_bug_for_fatal_signal(RETSIGTYPE (*default_sighandler)(int), int sig, const void *ctx, const char *fmt, ...)
{
const char *file = NULL;
int line = 0;
@@ -610,6 +610,8 @@ rb_bug_for_fatal_signal(const void *ctx, const char *fmt, ...)
report_bug(file, line, fmt, ctx);
+ if (default_sighandler) default_sighandler(sig);
+
die();
}