bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gnulib] xnanosleep.c: work around Linux-2.6.8.1 nanosleep bug


From: Jim Meyering
Subject: [bug-gnulib] xnanosleep.c: work around Linux-2.6.8.1 nanosleep bug
Date: Mon, 28 Feb 2005 11:17:05 +0100

I've checked in this change:

2005-02-27  Jim Meyering  <address@hidden>

        * xnanosleep.c (xnanosleep): Work around bug in Linux-2.6.8.1's
        nanosleep whereby it fails without setting errno upon being resumed
        after being suspended.

Index: xnanosleep.c
===================================================================
RCS file: /fetish/cu/lib/xnanosleep.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -p -u -r1.11 -r1.12
--- xnanosleep.c        21 Feb 2005 08:10:47 -0000      1.11
+++ xnanosleep.c        28 Feb 2005 10:02:58 -0000      1.12
@@ -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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]