if (st) {
pthread_attr_t a;
- sigset_t set;
+ sigset_t set, set_old;
pthread_t td;
if (sev->sigev_notify == SIGEV_THREAD) {
}
pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
sigfillset(&set);
- pthread_sigmask(SIG_BLOCK, &set, &set);
+ pthread_sigmask(SIG_BLOCK, &set, &set_old);
if (pthread_create(&td, &a, wait_thread, st)) {
free(st);
errno = EAGAIN;
return -1;
}
- pthread_sigmask(SIG_SETMASK, &set, 0);
+ pthread_sigmask(SIG_SETMASK, &set_old, 0);
}
return 0;
void (*sigset(int sig, void (*handler)(int)))(int)
{
struct sigaction sa, sa_old;
- sigset_t mask;
+ sigset_t mask, mask_old;
sigemptyset(&mask);
if (sigaddset(&mask, sig) < 0)
if (handler == SIG_HOLD) {
if (sigaction(sig, 0, &sa_old) < 0)
return SIG_ERR;
- if (sigprocmask(SIG_BLOCK, &mask, &mask) < 0)
+ if (sigprocmask(SIG_BLOCK, &mask, &mask_old) < 0)
return SIG_ERR;
} else {
sa.sa_handler = handler;
sigemptyset(&sa.sa_mask);
if (sigaction(sig, &sa, &sa_old) < 0)
return SIG_ERR;
- if (sigprocmask(SIG_UNBLOCK, &mask, &mask) < 0)
+ if (sigprocmask(SIG_UNBLOCK, &mask, &mask_old) < 0)
return SIG_ERR;
}
- return sigismember(&mask, sig) ? SIG_HOLD : sa_old.sa_handler;
+ return sigismember(&mask_old, sig) ? SIG_HOLD : sa_old.sa_handler;
}
struct itimerval it = {
.it_interval.tv_usec = interval,
.it_value.tv_usec = value
- };
- setitimer(ITIMER_REAL, &it, &it);
- return it.it_value.tv_sec*1000000 + it.it_value.tv_usec;
+ }, it_old;
+ setitimer(ITIMER_REAL, &it, &it_old);
+ return it_old.it_value.tv_sec*1000000 + it_old.it_value.tv_usec;
}