int sigaction(int signal, conststruct sigaction* bionic_new_action, struct sigaction* bionic_old_action) {
__kernel_sigaction kernel_new_action = {}; if (bionic_new_action != nullptr) {
kernel_new_action.sa_flags = bionic_new_action->sa_flags;
kernel_new_action.sa_handler = bionic_new_action->sa_handler; // Don't filter signals here; if the caller asked for everything to be blocked, we should obey.
kernel_new_action.sa_mask = bionic_new_action->sa_mask; #ifdefined(__x86_64__) // riscv64 doesn't have sa_restorer. For arm64 and 32-bit x86, unwinding // works best if you just let the kernel supply the default restorer // from [vdso]. gdb doesn't care, but libgcc needs the nop that the // kernel includes before the actual code. (We could add that ourselves, // but why bother?) // TODO: why do arm32 and x86-64 need this to unwind through signal handlers?
kernel_new_action.sa_restorer = bionic_new_action->sa_restorer; if (!(kernel_new_action.sa_flags & SA_RESTORER)) {
kernel_new_action.sa_flags |= SA_RESTORER;
kernel_new_action.sa_restorer = &__restore_rt;
} #endif
}
// sigaction and sigaction64 get interposed in ART: ensure that we don't end up calling // sigchain sigaction -> bionic sigaction -> sigchain sigaction64 -> bionic sigaction64 // by extracting the implementation of sigaction64 to a static function. staticint __sigaction64(int signal, conststruct sigaction64* bionic_new, struct sigaction64* bionic_old) { struct sigaction64 kernel_new = {}; if (bionic_new) {
kernel_new = *bionic_new; #ifdefined(__arm__) // (See sa_restorer comment in sigaction() above.) if (!(kernel_new.sa_flags & SA_RESTORER)) {
kernel_new.sa_flags |= SA_RESTORER;
kernel_new.sa_restorer = (kernel_new.sa_flags & SA_SIGINFO) ? &__restore_rt : &__restore;
} #endif // Don't filter signals here; if the caller asked for everything to be blocked, we should obey.
kernel_new.sa_mask = kernel_new.sa_mask;
}
int sigaction(int signal, conststruct sigaction* bionic_new, struct sigaction* bionic_old) { // The 32-bit ABI is broken. struct sigaction includes a too-small sigset_t, // so we have to translate to struct sigaction64 first. struct sigaction64 kernel_new = {}; if (bionic_new) {
kernel_new.sa_flags = bionic_new->sa_flags;
kernel_new.sa_handler = bionic_new->sa_handler; #ifdefined(SA_RESTORER)
kernel_new.sa_restorer = bionic_new->sa_restorer; #endif // Don't filter signals here; if the caller asked for everything to be blocked, we should obey.
memcpy(&kernel_new.sa_mask, &bionic_new->sa_mask, sizeof(bionic_new->sa_mask));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.