]> code.delx.au - gnu-emacs/blobdiff - m4/dup2.m4
Fix an error in Tramp for rsync
[gnu-emacs] / m4 / dup2.m4
index 59028e0982cc2990cabf2e71d565906b4337d7f4..5b68312b1e7f01680937ca782e3388603b46846c 100644 (file)
@@ -1,5 +1,5 @@
-#serial 24
-dnl Copyright (C) 2002, 2005, 2007, 2009-2015 Free Software Foundation, Inc.
+#serial 25
+dnl Copyright (C) 2002, 2005, 2007, 2009-2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -62,6 +62,16 @@ AC_DEFUN([gl_FUNC_DUP2],
                result |= 32;
              dup2 (2, 255);
              dup2 (2, 256);
+             /* On OS/2 kLIBC, dup2() does not work on a directory fd.  */
+             {
+               int fd = open (".", O_RDONLY);
+               if (fd == -1)
+                 result |= 64;
+               else if (dup2 (fd, fd + 1) == -1)
+                 result |= 128;
+
+               close (fd);
+             }
              return result;]])
         ],
         [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
@@ -78,6 +88,8 @@ AC_DEFUN([gl_FUNC_DUP2],
              gl_cv_func_dup2_works="guessing no" ;;
            *-android*) # implemented using dup3(), which fails if oldfd == newfd
              gl_cv_func_dup2_works="guessing no" ;;
+           os2*) # on OS/2 kLIBC, dup2() does not work on a directory fd.
+             gl_cv_func_dup2_works="guessing no" ;;
            *) gl_cv_func_dup2_works="guessing yes" ;;
          esac])
       ])