diff options
-rw-r--r-- | src/sighook.c | 7 | ||||
-rw-r--r-- | tests/sighook.c | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/sighook.c b/src/sighook.c index 6fd4c86..e74bb78 100644 --- a/src/sighook.c +++ b/src/sighook.c @@ -452,9 +452,16 @@ static void sigdispatch(int sig, siginfo_t *info, void *context) { // to die "correctly" (e.g. with a core dump pointing at the faulting // instruction, not reraise()). if (is_fault(info)) { + // On macOS, we cannot reliably distinguish between faults and + // asynchronous signals. For example, pkill -SEGV bfs will + // result in si_code == SEGV_ACCERR. So we always re-raise the + // signal, because just returning would cause us to ignore + // asynchronous SIG{BUS,ILL,SEGV}. +#if !__APPLE__ if (signal(sig, SIG_DFL) != SIG_ERR) { return; } +#endif reraise(sig); } diff --git a/tests/sighook.c b/tests/sighook.c index 3a715e6..ba1c424 100644 --- a/tests/sighook.c +++ b/tests/sighook.c @@ -216,5 +216,9 @@ void check_sighook(void) { check_sigexit(SIGINT); check_sigexit(SIGQUIT); check_sigexit(SIGPIPE); + + // macOS cannot distinguish between sync and async SIG{BUS,ILL,SEGV} +#if !__APPLE__ check_sigexit(SIGSEGV); +#endif } |