summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog30
-rw-r--r--doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi3
-rw-r--r--doc/posix-functions/posix_spawn.texi7
-rw-r--r--doc/posix-functions/posix_spawnp.texi7
-rw-r--r--lib/spawn.in.h35
-rw-r--r--lib/spawn_faction_addfchdir.c68
-rw-r--r--lib/spawn_int.h7
-rw-r--r--lib/spawni.c6
-rw-r--r--m4/posix_spawn.m411
-rw-r--r--m4/posix_spawn_faction_addfchdir.m420
-rw-r--r--m4/spawn_h.m454
-rw-r--r--modules/posix_spawn_file_actions_addfchdir30
-rw-r--r--modules/spawn3
-rw-r--r--tests/test-spawn-c++.cc5
14 files changed, 254 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index ac79aaca9c..ecf1d47fe1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,35 @@
2019-06-10 Bruno Haible <bruno@clisp.org>
+ posix_spawn_file_actions_addfchdir: New module.
+ * lib/spawn.in.h (posix_spawn_file_actions_addfchdir): New declaration.
+ * lib/spawn_int.h (struct __spawn_action): Add tag 'spawn_do_fchdir' and
+ union member 'fchdir_action'.
+ * lib/spawn_faction_addfchdir.c: New file.
+ * lib/spawni.c (__spawni): Implement the spawn_do_fchdir action.
+ * m4/posix_spawn_faction_addfchdir.m4: New file.
+ * m4/posix_spawn.m4 (gl_POSIX_SPAWN_BODY): Test whether module
+ 'posix_spawn_file_actions_addfchdir' is present and whether
+ posix_spawn_file_actions_addfchdir_np exists. Set REPLACE_POSIX_SPAWN.
+ * m4/spawn_h.m4 (gl_SPAWN_H): Test whether
+ posix_spawn_file_actions_addfchdir is declared.
+ (gl_SPAWN_H_DEFAULTS): Initialize
+ GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR,
+ HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR,
+ REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR.
+ * modules/spawn (Makefile.am): Substitute
+ GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR,
+ HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR,
+ REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR.
+ * modules/posix_spawn_file_actions_addfchdir: New file.
+ * tests/test-spawn-c++.cc (posix_spawn_file_actions_addfchdir): Check
+ signature.
+ * doc/posix-functions/posix_spawn.texi: Mention the new module.
+ * doc/posix-functions/posix_spawnp.texi: Likewise.
+ * doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi:
+ Likewise.
+
+2019-06-10 Bruno Haible <bruno@clisp.org>
+
doc: Document existence of posix_spawn_file_actions_addchdir module.
* doc/glibc-functions/posix_spawn_file_actions_addchdir_np.texi: Mention
the posix_spawn_file_actions_addchdir module.
diff --git a/doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi b/doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi
index bb82195337..6da90fd9d9 100644
--- a/doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi
+++ b/doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi
@@ -14,3 +14,6 @@ Portability problems not fixed by Gnulib:
This function is missing on all non-glibc platforms:
glibc 2.28, Mac OS X 10.5, FreeBSD 12.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.4, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
+
+Note: Gnulib has a module @code{posix_spawn_file_actions_addfchdir} that
+provides equivalent functionality, just without the suffix @code{_np}.
diff --git a/doc/posix-functions/posix_spawn.texi b/doc/posix-functions/posix_spawn.texi
index bed0e79490..651360885d 100644
--- a/doc/posix-functions/posix_spawn.texi
+++ b/doc/posix-functions/posix_spawn.texi
@@ -24,6 +24,7 @@ This function does not work on some platforms:
AIX 6.1 (under particular circumstances), mingw.
@end itemize
-The Gnulib module @code{posix_spawn_file_actions_addchdir} provides an
-additional action, that consists in changing the current directory of
-the child process before starting the specified program.
+The Gnulib modules @code{posix_spawn_file_actions_addchdir} and
+@code{posix_spawn_file_actions_addfchdir} provide additional actions,
+that consist in changing the current directory of the child process
+before starting the specified program.
diff --git a/doc/posix-functions/posix_spawnp.texi b/doc/posix-functions/posix_spawnp.texi
index 6cfec28dc6..3dd8ed4cc2 100644
--- a/doc/posix-functions/posix_spawnp.texi
+++ b/doc/posix-functions/posix_spawnp.texi
@@ -24,6 +24,7 @@ This function does not work on some platforms:
AIX 6.1 (under particular circumstances), mingw.
@end itemize
-The Gnulib module @code{posix_spawn_file_actions_addchdir} provides an
-additional action, that consists in changing the current directory of
-the child process before starting the specified program.
+The Gnulib modules @code{posix_spawn_file_actions_addchdir} and
+@code{posix_spawn_file_actions_addfchdir} provide additional actions,
+that consist in changing the current directory of the child process
+before starting the specified program.
diff --git a/lib/spawn.in.h b/lib/spawn.in.h
index df95e4a620..721d70f4b0 100644
--- a/lib/spawn.in.h
+++ b/lib/spawn.in.h
@@ -913,6 +913,41 @@ _GL_WARN_ON_USE (posix_spawn_file_actions_addchdir,
# endif
#endif
+#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ 'fchdir' to the given directory during the 'spawn' call. */
+# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define posix_spawn_file_actions_addfchdir rpl_posix_spawn_file_actions_addfchdir
+# endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd)
+ __THROW _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd));
+# else
+# if !@HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd)
+ __THROW _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+ int __fd));
+# endif
+_GL_CXXALIASWARN (posix_spawn_file_actions_addfchdir);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_addfchdir
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR
+_GL_WARN_ON_USE (posix_spawn_file_actions_addfchdir,
+ "posix_spawn_file_actions_addfchdir is unportable - "
+ "use gnulib module posix_spawn_file_actions_addfchdir for portability");
+# endif
+#endif
+
#endif /* _@GUARD_PREFIX@_SPAWN_H */
#endif /* _@GUARD_PREFIX@_SPAWN_H */
diff --git a/lib/spawn_faction_addfchdir.c b/lib/spawn_faction_addfchdir.c
new file mode 100644
index 0000000000..504856dab9
--- /dev/null
+++ b/lib/spawn_faction_addfchdir.c
@@ -0,0 +1,68 @@
+/* Copyright (C) 2018-2019 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <spawn.h>
+
+#include <errno.h>
+#include <unistd.h>
+
+#if !_LIBC
+# define __sysconf(open_max) getdtablesize ()
+#endif
+
+#if REPLACE_POSIX_SPAWN
+# include "spawn_int.h"
+#endif
+
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ 'fchdir' to the given directory during the 'spawn' call. */
+int
+posix_spawn_file_actions_addfchdir (posix_spawn_file_actions_t *file_actions,
+ int fd)
+#undef posix_spawn_file_actions_addfchdir
+{
+ int maxfd = __sysconf (_SC_OPEN_MAX);
+
+ /* Test for the validity of the file descriptor. */
+ if (fd < 0 || fd >= maxfd)
+ return EBADF;
+
+#if !REPLACE_POSIX_SPAWN
+ return posix_spawn_file_actions_addfchdir_np (file_actions, fd);
+#else
+ /* Allocate more memory if needed. */
+ if (file_actions->_used == file_actions->_allocated
+ && __posix_spawn_file_actions_realloc (file_actions) != 0)
+ /* This can only mean we ran out of memory. */
+ return ENOMEM;
+
+ {
+ struct __spawn_action *rec;
+
+ /* Add the new value. */
+ rec = &file_actions->_actions[file_actions->_used];
+ rec->tag = spawn_do_fchdir;
+ rec->action.fchdir_action.fd = fd;
+
+ /* Account for the new entry. */
+ ++file_actions->_used;
+
+ return 0;
+ }
+#endif
+}
diff --git a/lib/spawn_int.h b/lib/spawn_int.h
index 06b8004c8f..584c1bbcc3 100644
--- a/lib/spawn_int.h
+++ b/lib/spawn_int.h
@@ -24,7 +24,8 @@ struct __spawn_action
spawn_do_close,
spawn_do_dup2,
spawn_do_open,
- spawn_do_chdir
+ spawn_do_chdir,
+ spawn_do_fchdir
} tag;
union
@@ -49,6 +50,10 @@ struct __spawn_action
{
const char *path;
} chdir_action;
+ struct
+ {
+ int fd;
+ } fchdir_action;
} action;
};
diff --git a/lib/spawni.c b/lib/spawni.c
index 39e99a0b43..087f45c9c3 100644
--- a/lib/spawni.c
+++ b/lib/spawni.c
@@ -290,6 +290,12 @@ __spawni (pid_t *pid, const char *file,
/* The 'chdir' call failed. */
_exit (SPAWN_ERROR);
break;
+
+ case spawn_do_fchdir:
+ if (fchdir (action->action.fchdir_action.fd) < 0)
+ /* The 'fchdir' call failed. */
+ _exit (SPAWN_ERROR);
+ break;
}
}
}
diff --git a/m4/posix_spawn.m4 b/m4/posix_spawn.m4
index d50dcc9e2a..0128390d46 100644
--- a/m4/posix_spawn.m4
+++ b/m4/posix_spawn.m4
@@ -1,4 +1,4 @@
-# posix_spawn.m4 serial 16
+# posix_spawn.m4 serial 17
dnl Copyright (C) 2008-2019 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -42,6 +42,15 @@ AC_DEFUN([gl_POSIX_SPAWN_BODY],
REPLACE_POSIX_SPAWN=1
fi
])
+ m4_ifdef([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR],
+ [dnl Module 'posix_spawn_file_actions_addfchdir' is present.
+ AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addfchdir_np])
+ if test $ac_cv_func_posix_spawn_file_actions_addfchdir_np = no; then
+ dnl In order to implement the posix_spawn_file_actions_addfchdir
+ dnl function, we need to replace the entire posix_spawn facility.
+ REPLACE_POSIX_SPAWN=1
+ fi
+ ])
if test $REPLACE_POSIX_SPAWN = 0; then
gl_POSIX_SPAWN_WORKS
case "$gl_cv_func_posix_spawn_works" in
diff --git a/m4/posix_spawn_faction_addfchdir.m4 b/m4/posix_spawn_faction_addfchdir.m4
new file mode 100644
index 0000000000..ef2f9d6f28
--- /dev/null
+++ b/m4/posix_spawn_faction_addfchdir.m4
@@ -0,0 +1,20 @@
+# posix_spawn_faction_addfchdir.m4 serial 1
+dnl Copyright (C) 2018-2019 Free Software Foundation, Inc.
+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_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR],
+[
+ AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
+ AC_REQUIRE([AC_PROG_CC])
+ gl_POSIX_SPAWN
+ AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addfchdir posix_spawn_file_actions_addfchdir_np])
+ if test $ac_cv_func_posix_spawn_file_actions_addfchdir = yes; then
+ dnl This function is not yet standardized. Therefore override the
+ dnl system's implementation always.
+ REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=1
+ else
+ HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=0
+ fi
+])
diff --git a/m4/spawn_h.m4 b/m4/spawn_h.m4
index 561caa7745..95cb25d284 100644
--- a/m4/spawn_h.m4
+++ b/m4/spawn_h.m4
@@ -1,4 +1,4 @@
-# spawn_h.m4 serial 17
+# spawn_h.m4 serial 18
dnl Copyright (C) 2008-2019 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -53,7 +53,8 @@ AC_DEFUN([gl_SPAWN_H],
posix_spawnattr_getschedparam posix_spawnattr_setschedparam
posix_spawn_file_actions_init posix_spawn_file_actions_destroy
posix_spawn_file_actions_addopen posix_spawn_file_actions_addclose
- posix_spawn_file_actions_adddup2 posix_spawn_file_actions_addchdir])
+ posix_spawn_file_actions_adddup2 posix_spawn_file_actions_addchdir
+ posix_spawn_file_actions_addfchdir])
])
dnl Checks whether the system has the functions posix_spawn.
@@ -89,28 +90,29 @@ AC_DEFUN([gl_SPAWN_MODULE_INDICATOR],
AC_DEFUN([gl_SPAWN_H_DEFAULTS],
[
- GNULIB_POSIX_SPAWN=0; AC_SUBST([GNULIB_POSIX_SPAWN])
- GNULIB_POSIX_SPAWNP=0; AC_SUBST([GNULIB_POSIX_SPAWNP])
- GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT])
- GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
- GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE])
- GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2])
- GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN])
- GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY])
- GNULIB_POSIX_SPAWNATTR_INIT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_INIT])
- GNULIB_POSIX_SPAWNATTR_GETFLAGS=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETFLAGS])
- GNULIB_POSIX_SPAWNATTR_SETFLAGS=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETFLAGS])
- GNULIB_POSIX_SPAWNATTR_GETPGROUP=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETPGROUP])
- GNULIB_POSIX_SPAWNATTR_SETPGROUP=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETPGROUP])
- GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM])
- GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM])
- GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY])
- GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY])
- GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT])
- GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT])
- GNULIB_POSIX_SPAWNATTR_GETSIGMASK=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGMASK])
- GNULIB_POSIX_SPAWNATTR_SETSIGMASK=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGMASK])
- GNULIB_POSIX_SPAWNATTR_DESTROY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_DESTROY])
+ GNULIB_POSIX_SPAWN=0; AC_SUBST([GNULIB_POSIX_SPAWN])
+ GNULIB_POSIX_SPAWNP=0; AC_SUBST([GNULIB_POSIX_SPAWNP])
+ GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT])
+ GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
+ GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE])
+ GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2])
+ GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR])
+ GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN])
+ GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY])
+ GNULIB_POSIX_SPAWNATTR_INIT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_INIT])
+ GNULIB_POSIX_SPAWNATTR_GETFLAGS=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETFLAGS])
+ GNULIB_POSIX_SPAWNATTR_SETFLAGS=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETFLAGS])
+ GNULIB_POSIX_SPAWNATTR_GETPGROUP=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETPGROUP])
+ GNULIB_POSIX_SPAWNATTR_SETPGROUP=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETPGROUP])
+ GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM])
+ GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM])
+ GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY])
+ GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY])
+ GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT])
+ GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT])
+ GNULIB_POSIX_SPAWNATTR_GETSIGMASK=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGMASK])
+ GNULIB_POSIX_SPAWNATTR_SETSIGMASK=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGMASK])
+ GNULIB_POSIX_SPAWNATTR_DESTROY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_DESTROY])
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_POSIX_SPAWN=1; AC_SUBST([HAVE_POSIX_SPAWN])
HAVE_POSIX_SPAWNATTR_T=1; AC_SUBST([HAVE_POSIX_SPAWNATTR_T])
@@ -118,6 +120,8 @@ AC_DEFUN([gl_SPAWN_H_DEFAULTS],
AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_T])
HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=1;
AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
+ HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=1;
+ AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR])
REPLACE_POSIX_SPAWN=0; AC_SUBST([REPLACE_POSIX_SPAWN])
REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0;
AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
@@ -125,6 +129,8 @@ AC_DEFUN([gl_SPAWN_H_DEFAULTS],
AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE])
REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0;
AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2])
+ REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=0;
+ AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR])
REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0;
AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN])
])
diff --git a/modules/posix_spawn_file_actions_addfchdir b/modules/posix_spawn_file_actions_addfchdir
new file mode 100644
index 0000000000..cd9cb99f2f
--- /dev/null
+++ b/modules/posix_spawn_file_actions_addfchdir
@@ -0,0 +1,30 @@
+Description:
+posix_spawn_file_actions_addfchdir() function: augment a child process actions
+specification.
+
+Files:
+lib/spawn_faction_addfchdir.c
+lib/spawn_int.h
+m4/posix_spawn_faction_addfchdir.m4
+
+Depends-on:
+spawn
+posix_spawn_file_actions_init [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = 1]
+
+configure.ac:
+gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR
+if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = 1; then
+ AC_LIBOBJ([spawn_faction_addfchdir])
+fi
+gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_addfchdir])
+
+Makefile.am:
+
+Include:
+<spawn.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
diff --git a/modules/spawn b/modules/spawn
index dc861d3f6f..6e032943d1 100644
--- a/modules/spawn
+++ b/modules/spawn
@@ -35,6 +35,7 @@ spawn.h: spawn.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)/g' \
-e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE)/g' \
-e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2)/g' \
+ -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)/g' \
-e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN)/g' \
-e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY)/g' \
-e 's/@''GNULIB_POSIX_SPAWNATTR_INIT''@/$(GNULIB_POSIX_SPAWNATTR_INIT)/g' \
@@ -55,10 +56,12 @@ spawn.h: spawn.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's|@''HAVE_POSIX_SPAWNATTR_T''@|$(HAVE_POSIX_SPAWNATTR_T)|g' \
-e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_T''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_T)|g' \
-e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)|g' \
+ -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)|g' \
-e 's|@''REPLACE_POSIX_SPAWN''@|$(REPLACE_POSIX_SPAWN)|g' \
-e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)|g' \
-e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE)|g' \
-e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2)|g' \
+ -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)|g' \
-e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
diff --git a/tests/test-spawn-c++.cc b/tests/test-spawn-c++.cc
index 2ba1cc4bb3..119917ffed 100644
--- a/tests/test-spawn-c++.cc
+++ b/tests/test-spawn-c++.cc
@@ -137,6 +137,11 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::posix_spawn_file_actions_addchdir, int,
(posix_spawn_file_actions_t *, const char *));
#endif
+#if GNULIB_TEST_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR
+SIGNATURE_CHECK (GNULIB_NAMESPACE::posix_spawn_file_actions_addfchdir, int,
+ (posix_spawn_file_actions_t *, int));
+#endif
+
int
main ()