diff options
author | Guy David <49722543+guy-david@users.noreply.github.com> | 2025-02-08 15:16:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-08 15:16:26 +0200 |
commit | ef23ba7da34ca1285f10603cc4aa6441ab4530e6 (patch) | |
tree | f2bdf7bc7c80a32b84d9e8f414ccda6f388f61ab /llvm/lib/Support/Unix/Signals.inc | |
parent | 66bea0df75ccdd5ffed41d06c7301a116d11abcb (diff) | |
download | llvm-ef23ba7da34ca1285f10603cc4aa6441ab4530e6.zip llvm-ef23ba7da34ca1285f10603cc4aa6441ab4530e6.tar.gz llvm-ef23ba7da34ca1285f10603cc4aa6441ab4530e6.tar.bz2 |
[Support] Re-raise external signals (#125854)
Otherwise, the handler "swallows" the signal and the process continues
to execute. While this use case is peculiar, ignoring these signals
entirely seems more odd.
Diffstat (limited to 'llvm/lib/Support/Unix/Signals.inc')
-rw-r--r-- | llvm/lib/Support/Unix/Signals.inc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 2e7b467..30e5f40 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -80,7 +80,7 @@ using namespace llvm; -static void SignalHandler(int Sig); // defined below. +static void SignalHandler(int Sig, siginfo_t *Info, void *); static void InfoSignalHandler(int Sig); // defined below. using SignalHandlerFunctionType = void (*)(); @@ -313,8 +313,8 @@ static void RegisterHandlers() { // Not signal-safe. switch (Kind) { case SignalKind::IsKill: - NewHandler.sa_handler = SignalHandler; - NewHandler.sa_flags = SA_NODEFER | SA_RESETHAND | SA_ONSTACK; + NewHandler.sa_sigaction = SignalHandler; + NewHandler.sa_flags = SA_NODEFER | SA_RESETHAND | SA_ONSTACK | SA_SIGINFO; break; case SignalKind::IsInfo: NewHandler.sa_handler = InfoSignalHandler; @@ -370,7 +370,7 @@ void sys::CleanupOnSignal(uintptr_t Context) { } // The signal handler that runs. -static void SignalHandler(int Sig) { +static void SignalHandler(int Sig, siginfo_t *Info, void *) { // Restore the signal behavior to default, so that the program actually // crashes when we return and the signal reissues. This also ensures that if // we crash in our signal handler that the program will terminate immediately @@ -412,6 +412,11 @@ static void SignalHandler(int Sig) { if (Sig == SIGILL || Sig == SIGFPE || Sig == SIGTRAP) raise(Sig); #endif + + // Signal sent from another process, do not assume that continuing the + // execution would re-raise it. + if (Info->si_pid != getpid()) + raise(Sig); } static void InfoSignalHandler(int Sig) { |