From 366dcbde024220925a06ad170737683cedc51c9a Mon Sep 17 00:00:00 2001 From: Daniil Kulchenko Date: Fri, 19 Aug 2022 10:10:59 -0700 Subject: [PATCH] Work around Rosetta signal handling issue (#455) Rosetta does something strange to the signal handling registers but setting SA_SIGINFO prevents the issue from happening. Set the flag on XNU to work around the issue. --- libc/calls/sigaction.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc/calls/sigaction.c b/libc/calls/sigaction.c index e40179d45..b65e8ef51 100644 --- a/libc/calls/sigaction.c +++ b/libc/calls/sigaction.c @@ -183,6 +183,10 @@ static int __sigaction(int sig, const struct sigaction *act, if (IsXnu()) { ap->sa_restorer = (void *)&__sigenter_xnu; ap->sa_handler = (void *)&__sigenter_xnu; + + // mitigate Rosetta signal handling strangeness + // https://github.com/jart/cosmopolitan/issues/455 + ap->sa_flags |= SA_SIGINFO; } else if (IsLinux()) { if (!(ap->sa_flags & SA_RESTORER)) { ap->sa_flags |= SA_RESTORER;