Fix M1 Rosetta signal handling (#455) (#553)

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.
This commit is contained in:
Daniil Kulchenko 2022-08-19 13:00:50 -07:00 committed by GitHub
parent 1ce101c5a5
commit 2827df688a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -183,6 +183,10 @@ static int __sigaction(int sig, const struct sigaction *act,
if (IsXnu()) { if (IsXnu()) {
ap->sa_restorer = (void *)&__sigenter_xnu; ap->sa_restorer = (void *)&__sigenter_xnu;
ap->sa_handler = (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()) { } else if (IsLinux()) {
if (!(ap->sa_flags & SA_RESTORER)) { if (!(ap->sa_flags & SA_RESTORER)) {
ap->sa_flags |= SA_RESTORER; ap->sa_flags |= SA_RESTORER;