]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
crash-handler: Make sure we propagate the original siginfo 25399/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 5 Jun 2022 12:25:22 +0000 (14:25 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 16 Nov 2022 15:07:35 +0000 (16:07 +0100)
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.

src/core/crash-handler.c

index 561b7fc19c69452ad4644de6051c86343789865d..fced3ccf5aa6d87e76806df4e2aa1415b27f705d 100644 (file)
@@ -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);