summaryrefslogtreecommitdiff
path: root/m4/posix_spawn.m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2012-01-08 22:00:12 +0100
committerBruno Haible <bruno@clisp.org>2012-01-08 23:03:18 +0100
commit88236bad53d1dd5e6b8a592a724736bbd9db7851 (patch)
treebdb522555fe819ad7f6bc7bf4284331bdcfadfef /m4/posix_spawn.m4
parentfca3cc12dcd2bb7a75a57be2c29a1de417ff3536 (diff)
downloadgnulib-88236bad53d1dd5e6b8a592a724736bbd9db7851.tar.gz
posix_spawn_file_actions_addclose: Work around Solaris 11 2011-11 bug.
* m4/spawn_h.m4 (gl_SPAWN_H_DEFAULTS): Initialize REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE. * m4/posix_spawn.m4 (gl_POSIX_SPAWN_BODY): Define HAVE_WORKING_POSIX_SPAWN. (gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE): New macro. * lib/spawn.in.h (posix_spawn_file_actions_addclose): Test REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE, not REPLACE_POSIX_SPAWN. * lib/spawn_faction_addclose.c: Add workaround implementation if HAVE_WORKING_POSIX_SPAWN. * modules/spawn (Makefile): Substitute REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE. * modules/posix_spawn_file_actions_addclose (configure.ac): Invoke gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE. Test REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE, not REPLACE_POSIX_SPAWN. (Depends-on): Update conditions. * doc/posix-functions/posix_spawn_file_actions_addclose.texi: Mention the Solaris 11 bug.
Diffstat (limited to 'm4/posix_spawn.m4')
-rw-r--r--m4/posix_spawn.m446
1 files changed, 45 insertions, 1 deletions
diff --git a/m4/posix_spawn.m4 b/m4/posix_spawn.m4
index fea9b21d4a..378d6a53e5 100644
--- a/m4/posix_spawn.m4
+++ b/m4/posix_spawn.m4
@@ -1,4 +1,4 @@
-# posix_spawn.m4 serial 9
+# posix_spawn.m4 serial 10
dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -36,6 +36,9 @@ AC_DEFUN([gl_POSIX_SPAWN_BODY],
gl_POSIX_SPAWN_WORKS
case "$gl_cv_func_posix_spawn_works" in
*yes)
+ AC_DEFINE([HAVE_WORKING_POSIX_SPAWN], [1],
+ [Define if you have the posix_spawn and posix_spawnp functions and
+ they work.])
dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDULER
dnl evaluates to nonzero.
dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedpolicy])
@@ -397,3 +400,44 @@ AC_DEFUN([gl_PREREQ_POSIX_SPAWN_INTERNAL],
AC_CHECK_HEADERS([paths.h])
AC_CHECK_FUNCS([confstr sched_setparam sched_setscheduler setegid seteuid vfork])
])
+
+AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE],
+[
+ AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ gl_POSIX_SPAWN
+ if test $REPLACE_POSIX_SPAWN = 1; then
+ REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=1
+ else
+ dnl On Solaris 11 2011-11, posix_spawn_file_actions_addclose succeeds even
+ dnl if the fd argument is out of range.
+ AC_CACHE_CHECK([whether posix_spawn_file_actions_addclose works],
+ [gl_cv_func_posix_spawn_file_actions_addclose_works],
+ [AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+#include <spawn.h>
+int main ()
+{
+ posix_spawn_file_actions_t actions;
+ if (posix_spawn_file_actions_init (&actions) != 0)
+ return 1;
+ if (posix_spawn_file_actions_addclose (&actions, 10000000) == 0)
+ return 2;
+ return 0;
+}]])],
+ [gl_cv_func_posix_spawn_file_actions_addclose_works=yes],
+ [gl_cv_func_posix_spawn_file_actions_addclose_works=no],
+ [# Guess no on Solaris, yes otherwise.
+ case "$host_os" in
+ solaris*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no";;
+ *) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing yes";;
+ esac
+ ])
+ ])
+ case "$gl_cv_func_posix_spawn_file_actions_addclose_works" in
+ *yes) ;;
+ *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=1 ;;
+ esac
+ fi
+])