getcwd-lgpl: fix m4 to match relaxed test for BSD
[gnulib.git] / m4 / popen.m4
1 # popen.m4 serial 4
2 dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_POPEN],
8 [
9   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10   AC_CACHE_CHECK([whether popen works with closed stdin],
11     [gl_cv_func_popen_works],
12     [
13       AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
14 ]], [int result = 0;
15      FILE *child;
16      fclose (stdin);
17      fclose (stdout);
18      child = popen ("echo a", "r");
19      if (fgetc (child) != 'a')
20        result |= 1;
21      if (pclose (child) != 0)
22        result |= 2;
23      return result;
24 ])], [gl_cv_func_popen_works=yes], [gl_cv_func_popen_works=no],
25      dnl For now, only cygwin 1.5 or older is known to be broken.
26      [gl_cv_func_popen_works='guessing yes'])
27   ])
28   if test "$gl_cv_func_popen_works" = no; then
29     REPLACE_POPEN=1
30   fi
31 ])
32
33 # Prerequisites of lib/popen.c.
34 AC_DEFUN([gl_PREREQ_POPEN],
35 [
36   :
37 ])