2009-10-09 Eric Blake <ebb9@byu.net>
+ dup2: work around FreeBSD 6.1 bug
+ * m4/dup2.m4 (gl_FUNC_DUP2): Detect bug.
+ * doc/posix-functions/dup2.texi (dup2): Document it.
+ Reported by Nelson H. F. Beebe and Jim Meyering.
+
test-stat-time: port to buggy NFS clients
* tests/test-stat-time.c (main) [W32]: Reduce ifdefs.
(test_ctime): Also skip test if mtime and ctime are skewed.
This function may return @code{-EBADF} instead of @code{-1} on some platforms:
Linux releases between July 2008 and May 2009 (versions 2.6.27 to 2.6.29).
+@item
+This function returns @code{EMFILE} instead of @code{EBADF} for
+extremely large targets, which interferes with using
+@code{dup2(fd,fd)==fd)} as the minimal @code{EBADF} filter:
+FreeBSD 6.1, Cygwin 1.5.
+
@item
This function is missing on some older platforms.
@end itemize
-#serial 8
+#serial 9
dnl Copyright (C) 2002, 2005, 2007, 2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
else
AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
[AC_RUN_IFELSE([
- AC_LANG_PROGRAM([[#include <unistd.h>]],
+ AC_LANG_PROGRAM([[#include <unistd.h>
+#include <errno.h>]],
[if (dup2 (1, 1) == 0)
return 1;
close (0);
if (dup2 (0, 0) != -1)
- return 1;
+ return 2;
+ /* Many gnulib modules require POSIX conformance of EBADF. */
+ if (dup2 (1, 1000000) == -1 && errno != EBADF)
+ return 3;
return 0;
])
],
linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
# closed fd may yield -EBADF instead of -1 / errno=EBADF.
gl_cv_func_dup2_works=no;;
+ freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
+ gl_cv_func_dup2_works=no;;
*) gl_cv_func_dup2_works=yes;;
esac])
])