>From bf0fcb3d4614a69d52dc37b8487510cc6077e597 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 23 Feb 2015 10:34:40 -0800 Subject: [PATCH] dup2: doc and test for Android bug Reported by Kevin Cernekee in: http://lists.gnu.org/archive/html/bug-gnulib/2015-02/msg00125.html * doc/posix-functions/dup2.texi (dup2): Document the bug. * m4/dup2.m4 (gl_FUNC_DUP2): Test for the bug. --- ChangeLog | 8 ++++++++ doc/posix-functions/dup2.texi | 4 ++++ m4/dup2.m4 | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79ca882..c29b05c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2015-02-23 Paul Eggert + + dup2: doc and test for Android bug + Reported by Kevin Cernekee in: + http://lists.gnu.org/archive/html/bug-gnulib/2015-02/msg00125.html + * doc/posix-functions/dup2.texi (dup2): Document the bug. + * m4/dup2.m4 (gl_FUNC_DUP2): Test for the bug. + 2015-02-23 Kevin Cernekee Replace dup2() on Android diff --git a/doc/posix-functions/dup2.texi b/doc/posix-functions/dup2.texi index 6e501b5..d04ad07 100644 --- a/doc/posix-functions/dup2.texi +++ b/doc/posix-functions/dup2.texi @@ -25,6 +25,10 @@ This function crashes when invoked with valid arguments on some platforms: Cygwin 1.7.25. @item +This function fails with @code{EINVAL} when duplicating an fd to itself: +Android. + address@hidden This function resets the @code{FD_CLOEXEC} flag when duplicating an fd to itself on some platforms: Haiku. diff --git a/m4/dup2.m4 b/m4/dup2.m4 index 28dbe0a..59028e0 100644 --- a/m4/dup2.m4 +++ b/m4/dup2.m4 @@ -1,4 +1,4 @@ -#serial 23 +#serial 24 dnl Copyright (C) 2002, 2005, 2007, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -45,7 +45,7 @@ AC_DEFUN([gl_FUNC_DUP2], if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1) result |= 1; #endif - if (dup2 (1, 1) == 0) + if (dup2 (1, 1) != 1) result |= 2; #ifdef FD_CLOEXEC if (fcntl (1, F_GETFD) != FD_CLOEXEC) -- 2.1.0