diff options
author | Jim Meyering <jim@meyering.net> | 2005-02-28 10:02:58 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2005-02-28 10:02:58 +0000 |
commit | db042d202252bf0372b033775ffcffa23e826ac2 (patch) | |
tree | 5be2ab8b3497a1c1a87a8ea2b74802df71628a66 | |
parent | 9ba735560477dd255534134a69dc53cf834ac586 (diff) | |
download | coreutils-db042d202252bf0372b033775ffcffa23e826ac2.tar.xz |
(xnanosleep): Work around bug in Linux-2.6.8.1's
nanosleep whereby it fails without setting errno upon being resumed
after being suspended.
-rw-r--r-- | lib/xnanosleep.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/xnanosleep.c b/lib/xnanosleep.c index 8aa5e8a8d..5ac9f2ecd 100644 --- a/lib/xnanosleep.c +++ b/lib/xnanosleep.c @@ -123,9 +123,16 @@ xnanosleep (double seconds) ts_sleep.tv_nsec = BILLION - 1; } + /* Linux-2.6.8.1's nanosleep returns -1, but doesn't set errno + when resumed after being suspended. Earlier versions would + set errno to EINTR. nanosleep from linux-2.6.10, as well as + implementations by (all?) other vendors, doesn't return -1 + in that case; either it continues sleeping (if time remains) + or it returns zero (if the wake-up time has passed). */ + errno = 0; if (nanosleep (&ts_sleep, NULL) == 0) break; - if (errno != EINTR) + if (errno != EINTR && errno != 0) return -1; if (NANOSLEEP_BUG_WORKAROUND) |