diff options
author | Eric Blake <ebb9@byu.net> | 2009-08-19 07:15:54 -0600 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2009-08-19 07:42:30 -0600 |
commit | a8f637e3c49275e6789c05d67c1fbd1751e5610a (patch) | |
tree | c8a9a99c67133a009a59149dcc7b15e680ec1c1a /m4/popen.m4 | |
parent | 3ef64012bf653379fda629f5a6b619be4c1f2e69 (diff) | |
download | gnulib-a8f637e3c49275e6789c05d67c1fbd1751e5610a.tar.gz |
popen: fix cygwin 1.5 bug when stdin closed
* doc/posix-functions/popen.texi (popen): Document cygwin bugs.
* modules/popen: New file.
* modules/popen-tests: Likewise.
* tests/test-popen.c: Likewise.
* m4/popen.m4: Likewise.
* lib/popen.c: Likewise.
* lib/stdio.in.h (popen): New declaration.
* m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Add popen.
* modules/stdio (Makefile.am): Likewise.
* MODULES.html.sh (systems lacking POSIX:2008): Mention it.
Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'm4/popen.m4')
-rw-r--r-- | m4/popen.m4 | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/m4/popen.m4 b/m4/popen.m4 new file mode 100644 index 0000000000..f774a9efa4 --- /dev/null +++ b/m4/popen.m4 @@ -0,0 +1,34 @@ +# popen.m4 serial 1 +dnl Copyright (C) 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, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_POPEN], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_CACHE_CHECK([whether popen works with closed stdin], + [gl_cv_func_popen_works], + [ + AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h> +]], [FILE *child; + fclose (stdin); + fclose (stdout); + child = popen ("echo a", "r"); + return !(fgetc (child) == 'a' && pclose (child) == 0); +])], [gl_cv_func_popen_works=yes], [gl_cv_func_popen_works=no], + dnl For now, only cygwin 1.5 or older is known to be broken. + [gl_cv_func_popen_works='guessing yes']) + ]) + if test "$gl_cv_func_popen_works" = no; then + REPLACE_POPEN=1 + AC_LIBOBJ([popen]) + gl_PREREQ_POPEN + fi +]) + +# Prerequisites of lib/popen.c. +AC_DEFUN([gl_PREREQ_POPEN], +[ + AC_REQUIRE([AC_C_INLINE]) +]) |