/* Run a specific sighandler from the top of the sigdata stack. The 'info' * struct is prepopulated before the call is triggered as the result of a * reflected fault. */ static void __run_sighandler() { struct pthread_tcb *me = pthread_self(); __sigdelset(&me->sigpending, me->sigdata->info.si_signo); trigger_posix_signal(me->sigdata->info.si_signo, &me->sigdata->info, &me->sigdata->u_ctx); uthread_yield(FALSE, __exit_sighandler_cb, 0); }
/* This is the catch all akaros event->posix signal handler. All posix signals * are received in a single akaros event type. They are then dispatched from * this function to their proper posix signal handler */ static void handle_event(struct event_msg *ev_msg, unsigned int ev_type, void *data) { int sig_nr; struct siginfo info = {0}; info.si_code = SI_USER; assert(ev_msg); sig_nr = ev_msg->ev_arg1; trigger_posix_signal(sig_nr, &info, 0); }
/* Run through all pending sighandlers and trigger them with a NULL info field. * These handlers are triggered as the result of a pthread_kill(), and thus * don't require individual 'info' structs. */ static void __run_pending_sighandlers() { struct pthread_tcb *me = pthread_self(); sigset_t andset = me->sigpending & (~me->sigmask); for (int i = 1; i < _NSIG; i++) { if (__sigismember(&andset, i)) { __sigdelset(&me->sigpending, i); trigger_posix_signal(i, NULL, &me->sigdata->u_ctx); } } uthread_yield(FALSE, __exit_sighandler_cb, 0); }