diff options
author | ache <ache@FreeBSD.org> | 1997-08-14 06:23:48 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1997-08-14 06:23:48 +0000 |
commit | 6ee68884c1adf24ea324aac3cad3a320c98deec4 (patch) | |
tree | f675cd9bb18de26e8ebfd2897c7ebee1574ef953 /lib/libc/gen/usleep.c | |
parent | c852b1e121e478ef1f6d87f3d42c8d9c2f479d94 (diff) | |
download | FreeBSD-src-6ee68884c1adf24ea324aac3cad3a320c98deec4.zip FreeBSD-src-6ee68884c1adf24ea324aac3cad3a320c98deec4.tar.gz |
Break loop if error != EINTR occurse or it can take forever with
time_remaining unchanged
Diffstat (limited to 'lib/libc/gen/usleep.c')
-rw-r--r-- | lib/libc/gen/usleep.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c index 0bf2948..3a0dee1 100644 --- a/lib/libc/gen/usleep.c +++ b/lib/libc/gen/usleep.c @@ -35,6 +35,7 @@ static char sccsid[] = "@(#)usleep.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ +#include <errno.h> #include <sys/time.h> #include <signal.h> #include <unistd.h> @@ -68,7 +69,8 @@ usleep(useconds) do { (void)nanosleep(&time_to_sleep, &time_remaining); time_to_sleep = time_remaining; - } while (time_to_sleep.tv_sec != 0 || + } while (!errno || errno == EINTR || + time_to_sleep.tv_sec != 0 || time_to_sleep.tv_nsec != 0); } #else @@ -120,7 +122,8 @@ usleep(useconds) &omask); time_to_sleep = time_remaining; } while (!alarm_termination && - (time_to_sleep.tv_sec != 0 || + (!errno || errno == EINTR || + time_to_sleep.tv_sec != 0 || time_to_sleep.tv_nsec != 0)); if (!alarm_blocked) { |