summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1997-08-12 19:54:31 +0000
committerache <ache@FreeBSD.org>1997-08-12 19:54:31 +0000
commit73828b41484420d5d85a9e3fc412a05d1737e92d (patch)
tree1eae9c7d8dcbb06f23ae7623e4603456ee4e255e /lib
parent3a0de699cffd5b7b8d5586f0e9adcba97e36be90 (diff)
downloadFreeBSD-src-73828b41484420d5d85a9e3fc412a05d1737e92d.zip
FreeBSD-src-73828b41484420d5d85a9e3fc412a05d1737e92d.tar.gz
Rearrange itimerfix loop doing it inside SIGALRM handling section
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/sleep.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c
index d142a83..3405741 100644
--- a/lib/libc/gen/sleep.c
+++ b/lib/libc/gen/sleep.c
@@ -100,19 +100,6 @@ sleep(seconds)
int alarm_blocked;
if (seconds != 0) {
- again:
- /*
- * XXX
- * Hack to work around itimerfix(9) gratuitously limiting
- * the acceptable range for a struct timeval.tv_sec to
- * <= ITIMERMAX
- */
- if (seconds > ITIMERMAX) {
- rest = seconds - ITIMERMAX;
- seconds = ITIMERMAX;
- }
- time_to_sleep.tv_sec = seconds;
- time_to_sleep.tv_nsec = 0;
/* Block SIGALRM while fiddling with it */
sigemptyset(&mask);
@@ -132,6 +119,20 @@ sleep(seconds)
sigaction(SIGALRM, &act, &oact);
}
+ again:
+ /*
+ * XXX
+ * Hack to work around itimerfix(9) gratuitously limiting
+ * the acceptable range for a struct timeval.tv_sec to
+ * <= ITIMERMAX
+ */
+ if (seconds > ITIMERMAX) {
+ rest = seconds - ITIMERMAX;
+ seconds = ITIMERMAX;
+ }
+ time_to_sleep.tv_sec = seconds;
+ time_to_sleep.tv_nsec = 0;
+
/*
* signanosleep() uses the given mask for the lifetime of
* the syscall only - it resets on return. Note that the
@@ -142,12 +143,6 @@ sleep(seconds)
*/
signanosleep(&time_to_sleep, &time_remaining, &omask);
- if (!alarm_blocked) {
- /* Unwind */
- sigaction(SIGALRM, &oact, (struct sigaction *)0);
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0);
- }
-
if (rest != 0 &&
time_remaining.tv_sec == 0 &&
time_remaining.tv_nsec == 0) {
@@ -156,6 +151,12 @@ sleep(seconds)
goto again;
}
+ if (!alarm_blocked) {
+ /* Unwind */
+ sigaction(SIGALRM, &oact, (struct sigaction *)0);
+ sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0);
+ }
+
/* return how long is left */
rest += time_remaining.tv_sec;
if (time_remaining.tv_nsec > 0)
OpenPOWER on IntegriCloud