changeset 8227:8aa8914c86a3

* 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>.
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 24 Feb 2007 10:01:49 +0000
parents a02426de7f27
children 93084dc35013
files ChangeLog m4/nanosleep.m4
diffstat 2 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/m4/nanosleep.m4
+++ b/m4/nanosleep.m4
@@ -60,14 +60,20 @@
 	  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;