Skip to content

Commit

Permalink
Unmask signal before re-raising fatal signal
Browse files Browse the repository at this point in the history
On Linux, while the signal handler runs, that signal is masked, so in
the rb_bug_for_fatal_signal() code path we didn't get the default signal
action as intended. See signal(7). It worked fine on macOS, though.

Before:

    $ ./miniruby -e 'Process.kill :SIGSEGV, Process.pid'
    <snip>
    Aborted (core dumped)

After:

    $ ./miniruby -e 'Process.kill :SIGSEGV, Process.pid'
    <snip>
    Segmentation fault (core dumped)

Follow-up for 1ac0afa "rb_bug_for_fatal_signal: exit with the right
signal".
  • Loading branch information
XrXr committed Dec 18, 2023
1 parent 4b125b7 commit 002b6ea
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ interrupt_init(int argc, VALUE *argv, VALUE self)
}

void rb_malloc_info_show_results(void); /* gc.c */
#ifdef POSIX_SIGNAL
static void reset_sigmask(int sig);
#endif

void
ruby_default_signal(int sig)
Expand All @@ -413,6 +416,9 @@ ruby_default_signal(int sig)
rb_malloc_info_show_results();

signal(sig, SIG_DFL);
#ifdef POSIX_SIGNAL
reset_sigmask(sig);
#endif
raise(sig);
}

Expand Down

0 comments on commit 002b6ea

Please sign in to comment.