Add interaction with sigprocmask()

This commit is contained in:
Laurence Withers 2007-11-05 10:38:23 +00:00
parent 8cfa44019f
commit 9046c9b878
1 changed files with 8 additions and 1 deletions

View File

@ -95,7 +95,7 @@ lwevent_signalcb lwevent_signalfd_getcb(const struct lwevent_signal* si)
int lwevent_signalfd_setsigs(struct lwevent_signal* si, const sigset_t* mask)
{
sigset_t mnew;
sigset_t mnew, munmask, mmask;
mnew = *mask;
sigdelset(&mnew, SIGBUS);
@ -104,7 +104,12 @@ int lwevent_signalfd_setsigs(struct lwevent_signal* si, const sigset_t* mask)
sigdelset(&mnew, SIGSEGV);
if(TEMP_FAILURE_RETRY( signalfd(lwevent_get_fd(si->ev), &mnew) )) return -1;
/* unmask old signals, mask new ones */
TEMP_FAILURE_RETRY( sigprocmask(SIG_UNBLOCK, &si->mask) );
si->mask = mnew;
TEMP_FAILURE_RETRY( sigprocmask(SIG_BLOCK, &si->mask) );
return 0;
}
@ -121,6 +126,8 @@ void lwevent_signalfd_close(struct lwevent_signal* si)
{
if(!si) return;
TEMP_FAILURE_RETRY( sigprocmask(SIG_UNBLOCK, &si->mask) );
lwevent_free(si->ev);
free(si);
}