changeset 16921:f243ccee7232

fdopen: Allow implementations that don't reject invalid fd arguments. * m4/fdopen.m4 (gl_FUNC_FDOPEN): Let the test pass if fdopen(-1,...) succeeds. Reported by Rich Felker <dalias@aerifal.cx>.
author Bruno Haible <bruno@clisp.org>
date Wed, 20 Jun 2012 22:51:06 +0200
parents 3dd127ee27c3
children 937fc0f34278
files ChangeLog m4/fdopen.m4
diffstat 2 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-06-20  Bruno Haible  <bruno@clisp.org>
+
+	fdopen: Allow implementations that don't reject invalid fd arguments.
+	* m4/fdopen.m4 (gl_FUNC_FDOPEN): Let the test pass if fdopen(-1,...)
+	succeeds.
+	Reported by Rich Felker <dalias@aerifal.cx>.
+
 2012-06-20  Simon Josefsson  <simon@josefsson.org>
 
 	* modules/parse-duration-tests (test_parse_duration_LDADD): Don't
--- a/m4/fdopen.m4
+++ b/m4/fdopen.m4
@@ -1,4 +1,4 @@
-# fdopen.m4 serial 2
+# fdopen.m4 serial 3
 dnl Copyright (C) 2011-2012 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -25,10 +25,8 @@
   FILE *fp;
   errno = 0;
   fp = fdopen (-1, "r");
-  if (fp != NULL)
+  if (fp == NULL && errno == 0)
     return 1;
-  if (errno == 0)
-    return 2;
   return 0;
 }]])],
           [gl_cv_func_fdopen_works=yes],