|
@@ -49,50 +49,45 @@ unsigned int sleep (unsigned int sec)
|
|
|
unsigned int sleep (unsigned int seconds)
|
|
|
{
|
|
|
struct timespec ts = { .tv_sec = (long int) seconds, .tv_nsec = 0 };
|
|
|
- sigset_t set, oset;
|
|
|
+ sigset_t set;
|
|
|
unsigned int result;
|
|
|
|
|
|
|
|
|
- if (seconds == 0)
|
|
|
- {
|
|
|
+ if (seconds == 0) {
|
|
|
# ifdef CANCELLATION_P
|
|
|
- CANCELLATION_P (THREAD_SELF);
|
|
|
+ CANCELLATION_P (THREAD_SELF);
|
|
|
# endif
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
arrives even if SIGCHLD is ignored. We have to deal with it
|
|
|
in libc. We block SIGCHLD first. */
|
|
|
__sigemptyset (&set);
|
|
|
__sigaddset (&set, SIGCHLD);
|
|
|
- sigprocmask (SIG_BLOCK, &set, &oset);
|
|
|
+ sigprocmask (SIG_BLOCK, &set, &set);
|
|
|
|
|
|
-
|
|
|
- if (!__sigismember (&oset, SIGCHLD))
|
|
|
- {
|
|
|
- int saved_errno;
|
|
|
+
|
|
|
+ if (!__sigismember (&set, SIGCHLD)) {
|
|
|
struct sigaction oact;
|
|
|
|
|
|
- __sigemptyset (&set);
|
|
|
- __sigaddset (&set, SIGCHLD);
|
|
|
-
|
|
|
+
|
|
|
sigaction (SIGCHLD, NULL, &oact);
|
|
|
+ if (oact.sa_handler == SIG_IGN) {
|
|
|
+
|
|
|
|
|
|
- if (oact.sa_handler == SIG_IGN)
|
|
|
- {
|
|
|
-
|
|
|
+
|
|
|
result = nanosleep (&ts, &ts);
|
|
|
|
|
|
- saved_errno = errno;
|
|
|
-
|
|
|
- sigprocmask (SIG_SETMASK, &oset, NULL);
|
|
|
- __set_errno (saved_errno);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- sigprocmask (SIG_SETMASK, &oset, NULL);
|
|
|
+
|
|
|
+
|
|
|
+ and therefore we don't need to save/restore it. */
|
|
|
+
|
|
|
+ sigprocmask (SIG_SETMASK, &set, NULL);
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ sigprocmask (SIG_SETMASK, &set, NULL);
|
|
|
result = nanosleep (&ts, &ts);
|
|
|
}
|
|
|
}
|