From 3a0de699cffd5b7b8d5586f0e9adcba97e36be90 Mon Sep 17 00:00:00 2001 From: ache Date: Tue, 12 Aug 1997 19:47:01 +0000 Subject: [PATCH] Solve itimerfix() problem completely by using loop in 100000000 secs chunks --- lib/libc/gen/sleep.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c index b553bf747636..d142a83f1d28 100644 --- a/lib/libc/gen/sleep.c +++ b/lib/libc/gen/sleep.c @@ -63,6 +63,7 @@ sleep(seconds) struct timespec time_remaining; if (seconds != 0) { + again: /* * XXX * Hack to work around itimerfix(9) gratuitously limiting @@ -76,6 +77,15 @@ sleep(seconds) time_to_sleep.tv_sec = seconds; time_to_sleep.tv_nsec = 0; nanosleep(&time_to_sleep, &time_remaining); + + if (rest != 0 && + time_remaining.tv_sec == 0 && + time_remaining.tv_nsec == 0) { + seconds = rest; + rest = 0; + goto again; + } + rest += time_remaining.tv_sec; if (time_remaining.tv_nsec > 0) rest++; /* round up */ @@ -90,6 +100,7 @@ sleep(seconds) int alarm_blocked; if (seconds != 0) { + again: /* * XXX * Hack to work around itimerfix(9) gratuitously limiting @@ -137,6 +148,14 @@ sleep(seconds) sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0); } + if (rest != 0 && + time_remaining.tv_sec == 0 && + time_remaining.tv_nsec == 0) { + seconds = rest; + rest = 0; + goto again; + } + /* return how long is left */ rest += time_remaining.tv_sec; if (time_remaining.tv_nsec > 0)