From: Daan De Meyer Date: Sun, 5 Jun 2022 12:25:22 +0000 (+0200) Subject: crash-handler: Make sure we propagate the original siginfo X-Git-Tag: v253-rc1~511^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2af3e23fc085e6023b4906970f90757458fbb514;p=thirdparty%2Fsystemd.git crash-handler: Make sure we propagate the original siginfo If we call raise(), we lose the information from the original signal. If we use rt_sigqueueinfo(), the original siginfo gets reused which is helpful when debugging crashes. --- diff --git a/src/core/crash-handler.c b/src/core/crash-handler.c index 561b7fc19c6..fced3ccf5aa 100644 --- a/src/core/crash-handler.c +++ b/src/core/crash-handler.c @@ -47,10 +47,11 @@ _noreturn_ static void crash(int sig, siginfo_t *siginfo, void *context) { * memory allocation is not async-signal-safe anyway — see signal-safety(7) for details —, and thus * is not permissible in signal handlers.) */ - if (getpid_cached() != 1) + if (getpid_cached() != 1) { /* Pass this on immediately, if this is not PID 1 */ - (void) raise(sig); - else if (!arg_dump_core) + if (rt_tgsigqueueinfo(getpid_cached(), gettid(), sig, siginfo) < 0) + (void) raise(sig); + } else if (!arg_dump_core) log_emergency("Caught <%s>, not dumping core.", signal_to_string(sig)); else { sa = (struct sigaction) { @@ -80,7 +81,8 @@ _noreturn_ static void crash(int sig, siginfo_t *siginfo, void *context) { /* Raise the signal again */ pid = raw_getpid(); - (void) kill(pid, sig); /* raise() would kill the parent */ + if (rt_tgsigqueueinfo(pid, gettid(), sig, siginfo) < 0) + (void) kill(pid, sig); /* raise() would kill the parent */ assert_not_reached(); _exit(EXIT_EXCEPTION);