FreeBSD/lib/libthr/thread/thr_sig.c
/*
 * The signal handler wrapper is entered with all signal masked.
 */
The signal handler wrapper is entered with all signal masked.
The signal handler wrapper is entered with all signal masked .
static void
thr_sighandler(int sig, siginfo_t *info, void *_ucp)
{
	struct pthread *curthread;
	ucontext_t *ucp;
	struct sigaction act;
	struct usigaction *usa;
	int err;
	err = errno;
	curthread = _get_curthread();
	ucp = _ucp;
	usa = __libc_sigaction_slot(sig);
	_thr_rwl_rdlock(&usa->lock);
	act = usa->sigact;
	_thr_rwl_unlock(&usa->lock);
	errno = err;
	curthread->deferred_run = 0;
	if (THR_IN_CRITICAL(curthread) && SIGISMEMBER(_thr_deferset, sig)) {
		memcpy(&curthread->deferred_sigact, &act, sizeof(struct sigaction));
		memcpy(&curthread->deferred_siginfo, info, sizeof(siginfo_t));
		curthread->deferred_sigmask = ucp->uc_sigmask;
		ucp->uc_sigmask = _thr_deferset;
		return;
	}
	handle_signal(&act, sig, info, ucp);
}
static void thr_sighandler ( int sig , siginfo_t * info , void * _ucp ) { struct pthread * curthread ; ucontext_t * ucp ; struct sigaction act ; struct usigaction * usa ; int err ; err = errno ; curthread = _get_curthread ( ) ; ucp = _ucp ; usa = __libc_sigaction_slot ( sig ) ; _thr_rwl_rdlock ( & usa -> lock ) ; act = usa -> sigact ; _thr_rwl_unlock ( & usa -> lock ) ; errno = err ; curthread -> deferred_run = 0 ; if ( THR_IN_CRITICAL ( curthread ) && SIGISMEMBER ( _thr_deferset , sig ) ) { memcpy ( & curthread -> deferred_sigact , & act , sizeof ( struct sigaction ) ) ; memcpy ( & curthread -> deferred_siginfo , info , sizeof ( siginfo_t ) ) ; curthread -> deferred_sigmask = ucp -> uc_sigmask ; ucp -> uc_sigmask = _thr_deferset ; return ; } handle_signal ( & act , sig , info , ucp ) ; }
The signal handler wrapper is entered with all signal masked.
The signal handler wrapper is entered with all signal masked .
/*
	 * if a thread is in critical region, for example it holds low level locks,
	 * try to defer the signal processing, however if the signal is synchronous
	 * signal, it means a bad thing has happened, this is a programming error,
	 * resuming fault point can not help anything (normally causes deadloop),
	 * so here we let user code handle it immediately.
	 */ /* mask all signals, we will restore it later. */