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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user