|
@@ -50,6 +50,7 @@ unsigned int sleep (unsigned int seconds)
|
|
|
{
|
|
|
struct timespec ts = { .tv_sec = (long int) seconds, .tv_nsec = 0 };
|
|
|
sigset_t set;
|
|
|
+ struct sigaction oact;
|
|
|
unsigned int result;
|
|
|
|
|
|
|
|
@@ -62,33 +63,28 @@ unsigned int sleep (unsigned int seconds)
|
|
|
|
|
|
|
|
|
arrives even if SIGCHLD is ignored. We have to deal with it
|
|
|
- in libc. We block SIGCHLD first. */
|
|
|
+ in libc. */
|
|
|
+
|
|
|
__sigemptyset (&set);
|
|
|
__sigaddset (&set, SIGCHLD);
|
|
|
- sigprocmask (SIG_BLOCK, &set, &set);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+ sigaction (SIGCHLD, NULL, &oact);
|
|
|
+ if (oact.sa_handler == SIG_IGN) {
|
|
|
+
|
|
|
+ sigprocmask (SIG_BLOCK, &set, &set);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ result = nanosleep (&ts, &ts);
|
|
|
+
|
|
|
if (!__sigismember (&set, SIGCHLD)) {
|
|
|
- struct sigaction oact;
|
|
|
-
|
|
|
-
|
|
|
- sigaction (SIGCHLD, NULL, &oact);
|
|
|
- if (oact.sa_handler == SIG_IGN) {
|
|
|
-
|
|
|
- result = nanosleep (&ts, &ts);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- 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);
|
|
|
- }
|
|
|
+
|
|
|
+ IOW: we need to unblock SIGCHLD now. Do it. */
|
|
|
+
|
|
|
+ and therefore we don't need to save/restore it. */
|
|
|
+ sigprocmask (SIG_SETMASK, &set, NULL);
|
|
|
}
|
|
|
- else
|
|
|
- result = nanosleep (&ts, &ts);
|
|
|
|
|
|
if (result != 0)
|
|
|
|