Improve quality of raise(), abort(), and tkill()

This change fixes a nasty bug where SIG_IGN and SIG_DFL weren't working
as advertised on BSDs. This change also fixes the tkill() definition on
MacOS so it maps to __pthread_kill().
This commit is contained in:
Justine Tunney 2022-09-03 18:12:01 -07:00
parent c5659b93f8
commit c5c4dfcd21
12 changed files with 293 additions and 63 deletions

View file

@ -182,8 +182,11 @@ static int __sigaction(int sig, const struct sigaction *act,
ap = ©
if (IsXnu()) {
ap->sa_restorer = (void *)&__sigenter_xnu;
ap->sa_handler = (void *)&__sigenter_xnu;
if (rva < kSigactionMinRva) {
ap->sa_sigaction = (void *)(intptr_t)rva;
} else {
ap->sa_sigaction = (void *)&__sigenter_xnu;
}
// mitigate Rosetta signal handling strangeness
// https://github.com/jart/cosmopolitan/issues/455
ap->sa_flags |= SA_SIGINFO;
@ -193,11 +196,23 @@ static int __sigaction(int sig, const struct sigaction *act,
ap->sa_restorer = &__restore_rt;
}
} else if (IsNetbsd()) {
ap->sa_sigaction = (sigaction_f)__sigenter_netbsd;
if (rva < kSigactionMinRva) {
ap->sa_sigaction = (void *)(intptr_t)rva;
} else {
ap->sa_sigaction = (sigaction_f)__sigenter_netbsd;
}
} else if (IsFreebsd()) {
ap->sa_sigaction = (sigaction_f)__sigenter_freebsd;
if (rva < kSigactionMinRva) {
ap->sa_sigaction = (void *)(intptr_t)rva;
} else {
ap->sa_sigaction = (sigaction_f)__sigenter_freebsd;
}
} else if (IsOpenbsd()) {
ap->sa_sigaction = (sigaction_f)__sigenter_openbsd;
if (rva < kSigactionMinRva) {
ap->sa_sigaction = (void *)(intptr_t)rva;
} else {
ap->sa_sigaction = (sigaction_f)__sigenter_openbsd;
}
} else {
return enosys();
}