[llvm] [Support] Don't re-raise signals sent from kernel (PR #145759)
Alex Langford via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 8 14:46:48 PDT 2025
================
@@ -413,10 +413,22 @@ static void SignalHandler(int Sig, siginfo_t *Info, void *) {
raise(Sig);
#endif
- // Signal sent from another process, do not assume that continuing the
- // execution would re-raise it.
- if (Info->si_pid != getpid())
+ // Signal sent from another userspace process, do not assume that continuing
+ // the execution would re-raise it.
+ if (Info->si_pid != getpid() && Info->si_pid != 0) {
+#if defined(__linux__) || defined(__ANDROID__)
+ // Re-raising a signal via `raise` loses the original siginfo. Recent
+ // versions of linux (>= 3.9) support processes sending a signal to itself
+ // with arbitrary signal information using a syscall. If this syscall is
+ // unsupported, errno will be set to EPERM and `raise` will be used instead.
+ int retval = syscall(SYS_rt_tgsigqueueinfo, getpid(), syscall(SYS_gettid),
----------------
bulbazord wrote:
Makes sense, I'll update. Thanks!
https://github.com/llvm/llvm-project/pull/145759
More information about the llvm-commits
mailing list