aboutsummaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
authorPaul Eggert2014-06-11 13:03:46 -0700
committerPaul Eggert2014-06-11 13:03:46 -0700
commit0071d45b616f0e533818e65cc7307fbe4bd2a282 (patch)
tree3b4a8ec6a3eeea42da96c764ff66bfe94eccf505 /m4
parentdf907af0ddfc4282a6184f1b516cd92dbdf0093f (diff)
downloademacs-0071d45b616f0e533818e65cc7307fbe4bd2a282.tar.gz
emacs-0071d45b616f0e533818e65cc7307fbe4bd2a282.zip
Backport fcntl.h AIX fix from the trunk.
This fixes a bug with the shell freezing. See: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17598#185 Merge from gnulib, incorporating: 2014-05-31 dup2, fcntl, fcntl-h: port to AIX 7.1 * lib/fcntl.in.h, m4/dup2.m4, m4/fcntl.m4: Update from gnulib.
Diffstat (limited to 'm4')
-rw-r--r--m4/dup2.m412
-rw-r--r--m4/fcntl.m412
2 files changed, 21 insertions, 3 deletions
diff --git a/m4/dup2.m4 b/m4/dup2.m4
index 89638a0bfe3..6498fc20245 100644
--- a/m4/dup2.m4
+++ b/m4/dup2.m4
@@ -8,6 +8,7 @@ AC_DEFUN([gl_FUNC_DUP2],
8[ 8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST]) 10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CHECK_FUNCS_ONCE([getdtablesize])
11 m4_ifdef([gl_FUNC_DUP2_OBSOLETE], [ 12 m4_ifdef([gl_FUNC_DUP2_OBSOLETE], [
12 AC_CHECK_FUNCS_ONCE([dup2]) 13 AC_CHECK_FUNCS_ONCE([dup2])
13 if test $ac_cv_func_dup2 = no; then 14 if test $ac_cv_func_dup2 = no; then
@@ -23,6 +24,11 @@ AC_DEFUN([gl_FUNC_DUP2],
23#include <fcntl.h> 24#include <fcntl.h>
24#include <errno.h>]], 25#include <errno.h>]],
25 [int result = 0; 26 [int result = 0;
27#ifdef HAVE_GETDTABLESIZE
28 int bad_fd = getdtablesize ();
29#else
30 int bad_fd = 1000000;
31#endif
26#ifdef FD_CLOEXEC 32#ifdef FD_CLOEXEC
27 if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1) 33 if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
28 result |= 1; 34 result |= 1;
@@ -37,7 +43,7 @@ AC_DEFUN([gl_FUNC_DUP2],
37 if (dup2 (0, 0) != -1) 43 if (dup2 (0, 0) != -1)
38 result |= 8; 44 result |= 8;
39 /* Many gnulib modules require POSIX conformance of EBADF. */ 45 /* Many gnulib modules require POSIX conformance of EBADF. */
40 if (dup2 (2, 1000000) == -1 && errno != EBADF) 46 if (dup2 (2, bad_fd) == -1 && errno != EBADF)
41 result |= 16; 47 result |= 16;
42 /* Flush out some cygwin core dumps. */ 48 /* Flush out some cygwin core dumps. */
43 if (dup2 (2, -1) != -1 || errno != EBADF) 49 if (dup2 (2, -1) != -1 || errno != EBADF)
@@ -56,7 +62,9 @@ AC_DEFUN([gl_FUNC_DUP2],
56 linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a 62 linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
57 # closed fd may yield -EBADF instead of -1 / errno=EBADF. 63 # closed fd may yield -EBADF instead of -1 / errno=EBADF.
58 gl_cv_func_dup2_works="guessing no" ;; 64 gl_cv_func_dup2_works="guessing no" ;;
59 freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF. 65 aix* | freebsd*)
66 # on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE,
67 # not EBADF.
60 gl_cv_func_dup2_works="guessing no" ;; 68 gl_cv_func_dup2_works="guessing no" ;;
61 haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC. 69 haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
62 gl_cv_func_dup2_works="guessing no" ;; 70 gl_cv_func_dup2_works="guessing no" ;;
diff --git a/m4/fcntl.m4 b/m4/fcntl.m4
index 4a2771fae35..f824beb6597 100644
--- a/m4/fcntl.m4
+++ b/m4/fcntl.m4
@@ -19,7 +19,7 @@ AC_DEFUN([gl_FUNC_FCNTL],
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
20 AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) 20 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
21 AC_REQUIRE([AC_CANONICAL_HOST]) 21 AC_REQUIRE([AC_CANONICAL_HOST])
22 AC_CHECK_FUNCS_ONCE([fcntl]) 22 AC_CHECK_FUNCS_ONCE([fcntl getdtablesize])
23 if test $ac_cv_func_fcntl = no; then 23 if test $ac_cv_func_fcntl = no; then
24 gl_REPLACE_FCNTL 24 gl_REPLACE_FCNTL
25 else 25 else
@@ -28,11 +28,21 @@ AC_DEFUN([gl_FUNC_FCNTL],
28 AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly], 28 AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
29 [gl_cv_func_fcntl_f_dupfd_works], 29 [gl_cv_func_fcntl_f_dupfd_works],
30 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 30 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
31#ifdef HAVE_GETDTABLESIZE
32# include <unistd.h>
33#endif
31#include <fcntl.h> 34#include <fcntl.h>
32#include <errno.h> 35#include <errno.h>
33]], [[int result = 0; 36]], [[int result = 0;
37#ifdef HAVE_GETDTABLESIZE
38 int bad_fd = getdtablesize ();
39#else
40 int bad_fd = 1000000;
41#endif
34 if (fcntl (0, F_DUPFD, -1) != -1) result |= 1; 42 if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
35 if (errno != EINVAL) result |= 2; 43 if (errno != EINVAL) result |= 2;
44 if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4;
45 if (errno != EINVAL) result |= 8;
36 return result; 46 return result;
37 ]])], 47 ]])],
38 [gl_cv_func_fcntl_f_dupfd_works=yes], 48 [gl_cv_func_fcntl_f_dupfd_works=yes],