/* Return any pending signal or wait for one for the given time. */ static int do_sigwait (const sigset_t *set, int *sig) { int ret; #ifdef SIGCANCEL sigset_t tmpset; if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) # ifdef SIGSETXID || __builtin_expect (__sigismember (set, SIGSETXID), 0) # endif )) { /* Create a temporary mask without the bit for SIGCANCEL set. */ // We are not copying more than we have to. memcpy (&tmpset, set, _NSIG / 8); __sigdelset (&tmpset, SIGCANCEL); # ifdef SIGSETXID __sigdelset (&tmpset, SIGSETXID); # endif set = &tmpset; } #endif /* XXX The size argument hopefully will have to be changed to the real size of the user-level sigset_t. */ #ifdef INTERNAL_SYSCALL INTERNAL_SYSCALL_DECL (err); ret = INTERNAL_SYSCALL (rt_sigtimedwait, err, 4, CHECK_SIGSET (set), NULL, NULL, _NSIG / 8); if (! INTERNAL_SYSCALL_ERROR_P (ret, err)) { *sig = ret; ret = 0; } else ret = INTERNAL_SYSCALL_ERRNO (ret, err); #else ret = INLINE_SYSCALL (rt_sigtimedwait, 4, CHECK_SIGSET (set), NULL, NULL, _NSIG / 8); if (ret != -1) { *sig = ret; ret = 0; } else ret = errno; #endif return ret; }
static int do_sigsuspend (const sigset_t *set) { # ifdef __NR_rt_sigsuspend /* First try the RT signals. */ if (!__libc_missing_rt_sigs) { /* XXX The size argument hopefully will have to be changed to the real size of the user-level sigset_t. */ int saved_errno = errno; int result = INLINE_SYSCALL (rt_sigsuspend, 2, CHECK_SIGSET (set), _NSIG / 8); if (result >= 0 || errno != ENOSYS) return result; __set_errno (saved_errno); __libc_missing_rt_sigs = 1; } # endif return INLINE_SYSCALL (sigsuspend, 3, 0, 0, set->__val[0]); }
static int do_sigtimedwait (const sigset_t *set, siginfo_t *info, const struct timespec *timeout) { #ifdef SIGCANCEL sigset_t tmpset; if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) # ifdef SIGSETXID || __builtin_expect (__sigismember (set, SIGSETXID), 0) # endif )) { /* Create a temporary mask without the bit for SIGCANCEL set. */ // We are not copying more than we have to. memcpy (&tmpset, set, _NSIG / 8); __sigdelset (&tmpset, SIGCANCEL); # ifdef SIGSETXID __sigdelset (&tmpset, SIGSETXID); # endif set = &tmpset; } #endif /* XXX The size argument hopefully will have to be changed to the real size of the user-level sigset_t. */ int result = INLINE_SYSCALL (rt_sigtimedwait, 4, CHECK_SIGSET (set), CHECK_1 (info), timeout, _NSIG / 8); /* The kernel generates a SI_TKILL code in si_code in case tkill is used. tkill is transparently used in raise(). Since having SI_TKILL as a code is useful in general we fold the results here. */ if (result != -1 && info != NULL && info->si_code == SI_TKILL) info->si_code = SI_USER; return result; }