123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- #define __need_NULL
- #include <stddef.h>
- #include <sys/syscall.h>
- #include <signal.h>
- #include <cancel.h>
- #if (defined(__NR_rt_sigtimedwait) || (defined(__UCLIBC_USE_TIME64__) && defined(__NR_rt_sigtimedwait_time64))) && \
- defined(__UCLIBC_HAS_REALTIME__)
- #include <string.h>
- static int __NC(sigwait)(const sigset_t *set, int *sig)
- {
- int ret;
- do
-
- ret = __NC(sigtimedwait)(set, NULL, NULL);
- while (ret == -1 && errno == EINTR);
- if (ret != -1) {
- *sig = ret;
- ret = 0;
- } else
- ret = errno;
- return ret;
- }
- #else
- #include <unistd.h> /* smallint */
- static smallint was_sig;
- static void ignore_signal(int sig)
- {
- was_sig = sig;
- }
- static int __NC(sigwait)(const sigset_t *set, int *sig)
- {
- sigset_t tmp_mask;
- struct sigaction saved[NSIG];
- struct sigaction action;
- int save_errno;
- int this;
-
- __sigfillset (&tmp_mask);
-
- action.sa_handler = ignore_signal;
- action.sa_flags = 0;
- __sigfillset (&action.sa_mask);
-
- was_sig = -1;
- for (this = 1; this < NSIG; ++this)
- if (__sigismember (set, this))
- {
-
- __sigdelset (&tmp_mask, this);
-
-
-
- if (sigaction (this, &action, &saved[this]) != 0)
- goto restore_handler;
- }
-
- __NC(sigsuspend)(&tmp_mask);
- restore_handler:
- save_errno = errno;
- while (--this >= 1)
- if (__sigismember (set, this))
-
- sigaction (this, &saved[this], NULL);
- __set_errno (save_errno);
-
- *sig = was_sig;
- return was_sig == -1 ? -1 : 0;
- }
- #endif
- CANCELLABLE_SYSCALL(int, sigwait, (const sigset_t *set, int *sig), (set, sig))
|