summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1997-08-12 17:17:53 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1997-08-12 17:17:53 +0000
commit1ddf325cda5efe372f9462fac1aed0864512f5e1 (patch)
treef4b3fc71a3244122dd88dd4aac566f17b407d26d /lib/libc
parentfa23b4efb8b585f0b5e6e7880493834ed3c79700 (diff)
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/usleep.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c
index 4b7d3cc52470..c8e26cbd8999 100644
--- a/lib/libc/gen/usleep.c
+++ b/lib/libc/gen/usleep.c
@@ -44,10 +44,12 @@ static char sccsid[] = "@(#)usleep.c 8.1 (Berkeley) 6/4/93";
#endif
#ifndef _THREAD_SAFE
+static int alarm_termination;
+
static void
sleephandler()
{
- return;
+ alarm_termination++;
}
#endif /* _THREAD_SAFE */
@@ -66,7 +68,7 @@ usleep(useconds)
do {
nanosleep(&time_to_sleep, &time_remaining);
time_to_sleep = time_remaining;
- } while (time_to_sleep.tv_sec != 0 &&
+ } while (time_to_sleep.tv_sec != 0 ||
time_to_sleep.tv_nsec != 0);
}
#else
@@ -92,6 +94,7 @@ usleep(useconds)
sigaction(SIGALRM, &act, &oact);
mask = omask;
sigdelset(&mask, SIGALRM);
+ alarm_termination = 0;
/*
* signanosleep() uses the given mask for the lifetime of
@@ -102,8 +105,9 @@ usleep(useconds)
do {
signanosleep(&time_to_sleep, &time_remaining, &mask);
time_to_sleep = time_remaining;
- } while (time_to_sleep.tv_sec != 0 &&
- time_to_sleep.tv_nsec != 0);
+ } while (!alarm_termination &&
+ (time_to_sleep.tv_sec != 0 ||
+ time_to_sleep.tv_nsec != 0));
/* Unwind */
sigaction(SIGALRM, &oact, (struct sigaction *)0);