/* Block signals in MASK, returning the old mask. */ int sigblock (int mask) { sigset_t set, oset; sigset_set_old_mask (&set, mask); sigprocmask (SIG_BLOCK, &set, &oset); /* can't fail */ return sigset_get_old_mask (&oset); }
/* Set the mask of blocked signals to MASK, returning the old mask. */ static int sigsetmask (int mask) { sigset_t set, oset; sigset_set_old_mask (&set, mask); sigprocmask (SIG_SETMASK, &set, &oset); /* can't fail */ return sigset_get_old_mask (&oset); }
/* Block signals in MASK, returning the old mask. */ int __sigblock (int mask) { sigset_t set, oset; if (sigset_set_old_mask (&set, mask) < 0) return -1; if (__sigprocmask (SIG_BLOCK, &set, &oset) < 0) return -1; return sigset_get_old_mask (&oset); }
/* libc_hidden_proto(__sigpause) */ int __sigpause (int sig_or_mask, int is_sig) { sigset_t set; if (is_sig) { /* The modern X/Open implementation is requested. */ sigprocmask (SIG_BLOCK, NULL, &set); /* Bound-check sig_or_mask, remove it from the set. */ if (sigdelset (&set, sig_or_mask) < 0) return -1; } else sigset_set_old_mask (&set, sig_or_mask); return sigsuspend (&set); }
/* Set the mask of blocked signals to MASK, wait for a signal to arrive, and then restore the mask. */ static int do_sigpause (int sig_or_mask, int is_sig) { sigset_t set; if (is_sig != 0) { /* The modern X/Open implementation is requested. */ if (__sigprocmask (0, NULL, &set) < 0 || sigdelset (&set, sig_or_mask) < 0) return -1; } else if (sigset_set_old_mask (&set, sig_or_mask) < 0) return -1; /* Note the sigpause() is a cancellation point. But since we call sigsuspend() which itself is a cancellation point we do not have to do anything here. */ return __sigsuspend (&set); }
/* Set the mask of blocked signals to MASK, wait for a signal to arrive, and then restore the mask. */ int __sigpause (int sig_or_mask, int is_sig) { sigset_t set; if (is_sig) { /* The modern X/Open implementation is requested. */ sigprocmask (SIG_BLOCK, NULL, &set); /* Bound-check sig_or_mask, remove it from the set. */ if (sigdelset (&set, sig_or_mask) < 0) return -1; } else sigset_set_old_mask (&set, sig_or_mask); /* Note the sigpause() is a cancellation point. But since we call sigsuspend() which itself is a cancellation point we do not have to do anything here. */ return sigsuspend (&set); }