* m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Check for a nanosleep that
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 24 Feb 2007 10:01:49 +0000 (10:01 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 24 Feb 2007 10:01:49 +0000 (10:01 +0000)
loops on small arguments.  This attempts to avoid the problem
Bruno Haible reported for AIX 4.3.2 in
<http://lists.gnu.org/archive/html/bug-gnulib/2007-02/msg00309.html>.

ChangeLog
m4/nanosleep.m4

index 98e3f45..45b1fd9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-02-24  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Check for a nanosleep that
+       loops on small arguments.  This attempts to avoid the problem
+       Bruno Haible reported for AIX 4.3.2 in
+       <http://lists.gnu.org/archive/html/bug-gnulib/2007-02/msg00309.html>.
+
 2007-02-23  Bruno Haible  <bruno@clisp.org>
 
        * m4/perl.m4 (gl_PERL): Require version 5.005, not 5.003.
index af346b6..a03c37c 100644 (file)
@@ -60,14 +60,20 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
          static struct timespec ts_sleep;
          static struct timespec ts_remaining;
          static struct sigaction act;
+         if (! nanosleep)
+           return 1;
          act.sa_handler = check_for_SIGALRM;
-          sigemptyset (&act.sa_mask);
+         sigemptyset (&act.sa_mask);
          sigaction (SIGALRM, &act, NULL);
+         ts_sleep.tv_sec = 0;
+         ts_sleep.tv_nsec = 1;
+         alarm (1);
+         if (nanosleep (&ts_sleep, NULL) != 0)
+           return 1;
          ts_sleep.tv_sec = TYPE_MAXIMUM (time_t);
          ts_sleep.tv_nsec = 999999999;
          alarm (1);
          if (nanosleep (&ts_sleep, &ts_remaining) == -1 && errno == EINTR
-             && nanosleep
              && TYPE_MAXIMUM (time_t) - 10 < ts_remaining.tv_sec)
            return 0;
          return 119;