2 dnl Copyright (C) 2007-2020 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.
7 AC_DEFUN([gl_FUNC_FREOPEN],
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
16 AC_CACHE_CHECK([whether freopen works on closed fds],
17 [gl_cv_func_freopen_works_on_closed],
24 return !(freopen ("/dev/null", "r", stdin)
26 && !ferror (stdin) && feof (stdin));]])],
27 [gl_cv_func_freopen_works_on_closed=yes],
28 [gl_cv_func_freopen_works_on_closed=no],
30 *gnu*) gl_cv_func_freopen_works_on_closed="guessing no" ;;
31 *) gl_cv_func_freopen_works_on_closed="guessing yes";;
33 case $gl_cv_func_freopen_works_on_closed in
34 *no) REPLACE_FREOPEN=1;;
39 # Prerequisites of lib/freopen.c.
40 AC_DEFUN([gl_PREREQ_FREOPEN], [:])