2012-05-26 23:14:36 +00:00
|
|
|
#serial 18
|
|
|
|
dnl Copyright (C) 2002, 2005, 2007, 2009-2012 Free Software Foundation, Inc.
|
2011-06-25 08:40:38 +00:00
|
|
|
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_DUP2],
|
|
|
|
[
|
|
|
|
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
|
|
|
AC_REQUIRE([AC_CANONICAL_HOST])
|
|
|
|
m4_ifdef([gl_FUNC_DUP2_OBSOLETE], [
|
|
|
|
AC_CHECK_FUNCS_ONCE([dup2])
|
|
|
|
if test $ac_cv_func_dup2 = no; then
|
|
|
|
HAVE_DUP2=0
|
|
|
|
fi
|
|
|
|
], [
|
|
|
|
AC_DEFINE([HAVE_DUP2], [1], [Define to 1 if you have the 'dup2' function.])
|
|
|
|
])
|
|
|
|
if test $HAVE_DUP2 = 1; then
|
|
|
|
AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
|
|
|
|
[AC_RUN_IFELSE([
|
|
|
|
AC_LANG_PROGRAM([[#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>]],
|
|
|
|
[int result = 0;
|
|
|
|
#ifdef FD_CLOEXEC
|
|
|
|
if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
|
|
|
|
result |= 1;
|
|
|
|
#endif
|
|
|
|
if (dup2 (1, 1) == 0)
|
|
|
|
result |= 2;
|
|
|
|
#ifdef FD_CLOEXEC
|
|
|
|
if (fcntl (1, F_GETFD) != FD_CLOEXEC)
|
|
|
|
result |= 4;
|
|
|
|
#endif
|
|
|
|
close (0);
|
|
|
|
if (dup2 (0, 0) != -1)
|
|
|
|
result |= 8;
|
|
|
|
/* Many gnulib modules require POSIX conformance of EBADF. */
|
|
|
|
if (dup2 (2, 1000000) == -1 && errno != EBADF)
|
|
|
|
result |= 16;
|
|
|
|
return result;
|
|
|
|
])
|
|
|
|
],
|
|
|
|
[gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
|
|
|
|
[case "$host_os" in
|
|
|
|
mingw*) # on this platform, dup2 always returns 0 for success
|
2012-05-26 23:14:36 +00:00
|
|
|
gl_cv_func_dup2_works="guessing no" ;;
|
2011-06-25 08:40:38 +00:00
|
|
|
cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
|
2012-05-26 23:14:36 +00:00
|
|
|
gl_cv_func_dup2_works="guessing no" ;;
|
2011-06-25 08:40:38 +00:00
|
|
|
linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
|
|
|
|
# closed fd may yield -EBADF instead of -1 / errno=EBADF.
|
2012-05-26 23:14:36 +00:00
|
|
|
gl_cv_func_dup2_works="guessing no" ;;
|
2011-06-25 08:40:38 +00:00
|
|
|
freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
|
2012-05-26 23:14:36 +00:00
|
|
|
gl_cv_func_dup2_works="guessing no" ;;
|
2011-06-25 08:40:38 +00:00
|
|
|
haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
|
2012-05-26 23:14:36 +00:00
|
|
|
gl_cv_func_dup2_works="guessing no" ;;
|
|
|
|
*) gl_cv_func_dup2_works="guessing yes" ;;
|
2011-06-25 08:40:38 +00:00
|
|
|
esac])
|
|
|
|
])
|
2012-05-26 23:14:36 +00:00
|
|
|
case "$gl_cv_func_dup2_works" in
|
|
|
|
*yes) ;;
|
|
|
|
*)
|
|
|
|
REPLACE_DUP2=1
|
|
|
|
;;
|
|
|
|
esac
|
2011-06-25 08:40:38 +00:00
|
|
|
fi
|
2011-07-28 16:35:19 +00:00
|
|
|
dnl Replace dup2() for supporting the gnulib-defined fchdir() function,
|
|
|
|
dnl to keep fchdir's bookkeeping up-to-date.
|
|
|
|
m4_ifdef([gl_FUNC_FCHDIR], [
|
|
|
|
gl_TEST_FCHDIR
|
|
|
|
if test $HAVE_FCHDIR = 0; then
|
2012-05-26 23:14:36 +00:00
|
|
|
if test $HAVE_DUP2 = 1; then
|
|
|
|
REPLACE_DUP2=1
|
|
|
|
fi
|
2011-07-28 16:35:19 +00:00
|
|
|
fi
|
|
|
|
])
|
2011-06-25 08:40:38 +00:00
|
|
|
])
|
Merge from gnulib, improving some licensing wording.
This clarifies and fixes some licensing issues raised by Glenn Morris
<http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00397.html>.
It also merges the latest version of texinfo.tex and has some
MSVC-related changes that don't affect Emacs.
* Makefile.in (GNULIB_TOOL_FLAGS): Avoid msvc-inval, msvc-nothrow,
pathmax, and raise, since these are needed only to address
MSVC-related issues that Emacs doesn't have.
* doc/misc/texinfo.tex, lib/dup2.c, lib/gnulib.mk, lib/signal.in.h:
* lib/sigprocmask.c, lib/stat.c, lib/stdio.in.h, lib/sys_stat.in.h:
* lib/unistd.in.h, m4/dup2.m4, m4/getloadavg.m4, m4/gl-comp.m4:
* m4/include_next.m4, m4/signal_h.m4, m4/signalblocking.m4:
* m4/stdint.m4, m4/stdio_h.m4, m4/sys_stat_h.m4, m4/time_h.m4:
* m4/unistd_h.m4: Merge from gnulib.
2011-09-26 21:30:18 +00:00
|
|
|
|
|
|
|
# Prerequisites of lib/dup2.c.
|
|
|
|
AC_DEFUN([gl_PREREQ_DUP2], [])
|