]> Savannah Git Hosting - gnulib.git/commitdiff
posix_spawn_file_actions_addchdir: New module.
authorBruno Haible <bruno@clisp.org>
Fri, 7 Sep 2018 21:35:52 +0000 (23:35 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 7 Sep 2018 21:37:01 +0000 (23:37 +0200)
Suggested by Eric Blake in
<https://lists.gnu.org/archive/html/bug-findutils/2018-09/msg00007.html>.

* lib/spawn.in.h (posix_spawn_file_actions_addchdir): New declaration.
* lib/spawn_int.h (struct __spawn_action): Add tag 'spawn_do_chdir' and
union member 'chdir_action'.
* lib/spawn_faction_addchdir.c: New file.
* lib/spawni.c (__spawni): Implement the spawn_do_chdir action.
* lib/spawn_faction_addclose.c: Test REPLACE_POSIX_SPAWN instead of
HAVE_WORKING_POSIX_SPAWN.
* lib/spawn_faction_adddup2.c: Likewise.
* lib/spawn_faction_addopen.c: Likewise.
* m4/posix_spawn_faction_addchdir.m4: New file.
* m4/posix_spawn.m4 (gl_POSIX_SPAWN_BODY): Test whether module
'posix_spawn_file_actions_addchdir' is present and whether
posix_spawn_file_actions_addchdir_np exists. Define REPLACE_POSIX_SPAWN
instead of HAVE_WORKING_POSIX_SPAWN.
* m4/spawn_h.m4 (gl_SPAWN_H): Test whether
posix_spawn_file_actions_addchdir is declared.
(gl_SPAWN_H_DEFAULTS): Initialize
GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR,
HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR,
REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR.
* modules/spawn (Makefile.am): Substitute
GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR,
HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR,
REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR.
* modules/posix_spawn_file_actions_addchdir: New file.
* modules/posix_spawn_file_actions_addclose (Depends-on,
configure.ac): Test also REPLACE_POSIX_SPAWN.
* modules/posix_spawn_file_actions_adddup2 (Depends-on,
configure.ac): Likewise.
* modules/posix_spawn_file_actions_addopen (Depends-on,
configure.ac): Likewise.
* tests/test-spawn-c++.cc (posix_spawn_file_actions_addchdir): Check
signature.
* doc/posix-functions/posix_spawn.texi: Mention the new module.
* doc/posix-functions/posix_spawnp.texi: Likewise.

19 files changed:
ChangeLog
doc/posix-functions/posix_spawn.texi
doc/posix-functions/posix_spawnp.texi
lib/spawn.in.h
lib/spawn_faction_addchdir.c [new file with mode: 0644]
lib/spawn_faction_addclose.c
lib/spawn_faction_adddup2.c
lib/spawn_faction_addopen.c
lib/spawn_int.h
lib/spawni.c
m4/posix_spawn.m4
m4/posix_spawn_faction_addchdir.m4 [new file with mode: 0644]
m4/spawn_h.m4
modules/posix_spawn_file_actions_addchdir [new file with mode: 0644]
modules/posix_spawn_file_actions_addclose
modules/posix_spawn_file_actions_adddup2
modules/posix_spawn_file_actions_addopen
modules/spawn
tests/test-spawn-c++.cc

index 12372c7c3dd72275768e5808b916da89e5754ef8..bb90832c573646c7aa76bee002de267dcb517e8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,44 @@
+2018-09-07  Bruno Haible  <bruno@clisp.org>
+
+       posix_spawn_file_actions_addchdir: New module.
+       Suggested by Eric Blake in
+       <https://lists.gnu.org/archive/html/bug-findutils/2018-09/msg00007.html>.
+       * lib/spawn.in.h (posix_spawn_file_actions_addchdir): New declaration.
+       * lib/spawn_int.h (struct __spawn_action): Add tag 'spawn_do_chdir' and
+       union member 'chdir_action'.
+       * lib/spawn_faction_addchdir.c: New file.
+       * lib/spawni.c (__spawni): Implement the spawn_do_chdir action.
+       * lib/spawn_faction_addclose.c: Test REPLACE_POSIX_SPAWN instead of
+       HAVE_WORKING_POSIX_SPAWN.
+       * lib/spawn_faction_adddup2.c: Likewise.
+       * lib/spawn_faction_addopen.c: Likewise.
+       * m4/posix_spawn_faction_addchdir.m4: New file.
+       * m4/posix_spawn.m4 (gl_POSIX_SPAWN_BODY): Test whether module
+       'posix_spawn_file_actions_addchdir' is present and whether
+       posix_spawn_file_actions_addchdir_np exists. Define REPLACE_POSIX_SPAWN
+       instead of HAVE_WORKING_POSIX_SPAWN.
+       * m4/spawn_h.m4 (gl_SPAWN_H): Test whether
+       posix_spawn_file_actions_addchdir is declared.
+       (gl_SPAWN_H_DEFAULTS): Initialize
+       GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR,
+       HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR,
+       REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR.
+       * modules/spawn (Makefile.am): Substitute
+       GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR,
+       HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR,
+       REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR.
+       * modules/posix_spawn_file_actions_addchdir: New file.
+       * modules/posix_spawn_file_actions_addclose (Depends-on,
+       configure.ac): Test also REPLACE_POSIX_SPAWN.
+       * modules/posix_spawn_file_actions_adddup2 (Depends-on,
+       configure.ac): Likewise.
+       * modules/posix_spawn_file_actions_addopen (Depends-on,
+       configure.ac): Likewise.
+       * tests/test-spawn-c++.cc (posix_spawn_file_actions_addchdir): Check
+       signature.
+       * doc/posix-functions/posix_spawn.texi: Mention the new module.
+       * doc/posix-functions/posix_spawnp.texi: Likewise.
+
 2018-09-06  Bruno Haible  <bruno@clisp.org>
 
        stddef: Override max_align_t on NetBSD 8.0/x86.
index 30e491b280509478e7b677b0a31f5d8a8f0c5683..bed0e794901d67ecd3af94c9fe688a0f3fd194cc 100644 (file)
@@ -23,3 +23,7 @@ Portability problems not fixed by Gnulib:
 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.
index 01446fcd8a686895f207108f1a2517ed6b318be4..6cfec28dc60b28d013dec6485c3b4519268bb38d 100644 (file)
@@ -23,3 +23,7 @@ Portability problems not fixed by Gnulib:
 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.
index a606176523d205e8e7a5be7b2e5f4bc30ecdef4e..7460c651b64ffc8739685142c2b7c18c89fca444 100644 (file)
@@ -878,6 +878,41 @@ _GL_WARN_ON_USE (posix_spawn_file_actions_adddup2,
 # endif
 #endif
 
+#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+   'chdir' to the given directory during the 'spawn' call.  */
+# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define posix_spawn_file_actions_addchdir rpl_posix_spawn_file_actions_addchdir
+#  endif
+_GL_FUNCDECL_RPL (posix_spawn_file_actions_addchdir, int,
+                  (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+                   const char *_Restrict_ __path)
+                  __THROW _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (posix_spawn_file_actions_addchdir, int,
+                  (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+                   const char *_Restrict_ __path));
+# else
+#  if !@HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
+_GL_FUNCDECL_SYS (posix_spawn_file_actions_addchdir, int,
+                  (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+                   const char *_Restrict_ __path)
+                  __THROW _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (posix_spawn_file_actions_addchdir, int,
+                  (posix_spawn_file_actions_t *_Restrict_ __file_actions,
+                   const char *_Restrict_ __path));
+# endif
+_GL_CXXALIASWARN (posix_spawn_file_actions_addchdir);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_spawn_file_actions_addchdir
+# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR
+_GL_WARN_ON_USE (posix_spawn_file_actions_addchdir,
+                 "posix_spawn_file_actions_addchdir is unportable - "
+                 "use gnulib module posix_spawn_file_actions_addchdir for portability");
+# endif
+#endif
+
 
 #endif /* _@GUARD_PREFIX@_SPAWN_H */
 #endif /* _@GUARD_PREFIX@_SPAWN_H */
diff --git a/lib/spawn_faction_addchdir.c b/lib/spawn_faction_addchdir.c
new file mode 100644 (file)
index 0000000..027cd8d
--- /dev/null
@@ -0,0 +1,57 @@
+/* Copyright (C) 2018 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>
+
+#if REPLACE_POSIX_SPAWN
+# include "spawn_int.h"
+#endif
+
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+   'chdir' to the given directory during the 'spawn' call.  */
+int
+posix_spawn_file_actions_addchdir (posix_spawn_file_actions_t *file_actions,
+                                   const char *path)
+#undef posix_spawn_file_actions_addchdir
+{
+#if !REPLACE_POSIX_SPAWN
+  return posix_spawn_file_actions_addchdir_np (file_actions, path);
+#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_chdir;
+    rec->action.chdir_action.path = path;
+
+    /* Account for the new entry.  */
+    ++file_actions->_used;
+
+    return 0;
+  }
+#endif
+}
index 93827dcae7be9b763edb643c3ce295f1ee01fee4..bac6cff8fcd32c85181be9785671ab548309dede 100644 (file)
@@ -26,7 +26,7 @@
 # define __sysconf(open_max) getdtablesize ()
 #endif
 
-#if !HAVE_WORKING_POSIX_SPAWN
+#if REPLACE_POSIX_SPAWN
 # include "spawn_int.h"
 #endif
 
@@ -43,7 +43,7 @@ posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *file_actions,
   if (fd < 0 || fd >= maxfd)
     return EBADF;
 
-#if HAVE_WORKING_POSIX_SPAWN
+#if !REPLACE_POSIX_SPAWN
   return posix_spawn_file_actions_addclose (file_actions, fd);
 #else
   /* Allocate more memory if needed.  */
index 86ae0af8e860e39ba367ee84412fa4a61726347a..fc25fb8df7ba7a2e6b9c85438b02b9f1a1f2800d 100644 (file)
@@ -26,7 +26,7 @@
 # define __sysconf(open_max) getdtablesize ()
 #endif
 
-#if !HAVE_WORKING_POSIX_SPAWN
+#if REPLACE_POSIX_SPAWN
 # include "spawn_int.h"
 #endif
 
@@ -43,7 +43,7 @@ posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *file_actions,
   if (fd < 0 || newfd < 0 || fd >= maxfd || newfd >= maxfd)
     return EBADF;
 
-#if HAVE_WORKING_POSIX_SPAWN
+#if !REPLACE_POSIX_SPAWN
   return posix_spawn_file_actions_adddup2 (file_actions, fd, newfd);
 #else
   /* Allocate more memory if needed.  */
index 5b62142c15dac99ae52e1334644d154e6ea5905b..8fa11413d3c173317e10ed6d069228ea4faccf3f 100644 (file)
@@ -26,7 +26,7 @@
 # define __sysconf(open_max) getdtablesize ()
 #endif
 
-#if !HAVE_WORKING_POSIX_SPAWN
+#if REPLACE_POSIX_SPAWN
 # include "spawn_int.h"
 #endif
 
@@ -44,7 +44,7 @@ posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *file_actions,
   if (fd < 0 || fd >= maxfd)
     return EBADF;
 
-#if HAVE_WORKING_POSIX_SPAWN
+#if !REPLACE_POSIX_SPAWN
   return posix_spawn_file_actions_addopen (file_actions, fd, path, oflag, mode);
 #else
   /* Allocate more memory if needed.  */
index 909122e33839500289072f8dc03f7120ffe4749a..f4b4be6bb877799f1f9927fb3e2cd5a6c0fe9ceb 100644 (file)
@@ -23,7 +23,8 @@ struct __spawn_action
   {
     spawn_do_close,
     spawn_do_dup2,
-    spawn_do_open
+    spawn_do_open,
+    spawn_do_chdir
   } tag;
 
   union
@@ -44,6 +45,10 @@ struct __spawn_action
       int oflag;
       mode_t mode;
     } open_action;
+    struct
+    {
+      const char *path;
+    } chdir_action;
   } action;
 };
 
index 40f89d2db62a52e0d4acbbebda830c3baf6649a3..bd49cc88ad5e5d185801c9f37731d76090621704 100644 (file)
@@ -284,6 +284,12 @@ __spawni (pid_t *pid, const char *file,
                 /* The 'dup2' call failed.  */
                 _exit (SPAWN_ERROR);
               break;
+
+            case spawn_do_chdir:
+              if (chdir (action->action.chdir_action.path) < 0)
+                /* The 'chdir' call failed.  */
+                _exit (SPAWN_ERROR);
+              break;
             }
         }
     }
index 685f0f4de94d18f7e5ee0951dd32aece393ef7d4..f656cfcdf1da1c2a2f5230d0fc047cf1b97b2ac5 100644 (file)
@@ -1,4 +1,4 @@
-# posix_spawn.m4 serial 14
+# posix_spawn.m4 serial 15
 dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -33,45 +33,57 @@ AC_DEFUN([gl_POSIX_SPAWN_BODY],
   dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setsigmask])
   dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_destroy])
   if test $ac_cv_func_posix_spawn = yes; then
-    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])
-        dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedpolicy])
-        AC_CACHE_CHECK([whether posix_spawnattr_setschedpolicy is supported],
-          [gl_cv_func_spawnattr_setschedpolicy],
-          [AC_EGREP_CPP([POSIX scheduling supported], [
+    m4_ifdef([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR],
+      [dnl Module 'posix_spawn_file_actions_addchdir' is present.
+       AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addchdir_np])
+       if test $ac_cv_func_posix_spawn_file_actions_addchdir_np = no; then
+         dnl In order to implement the posix_spawn_file_actions_addchdir
+         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
+        *yes)
+          dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDULER
+          dnl evaluates to nonzero.
+          dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedpolicy])
+          dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedpolicy])
+          AC_CACHE_CHECK([whether posix_spawnattr_setschedpolicy is supported],
+            [gl_cv_func_spawnattr_setschedpolicy],
+            [AC_EGREP_CPP([POSIX scheduling supported], [
 #include <spawn.h>
 #if POSIX_SPAWN_SETSCHEDULER
  POSIX scheduling supported
 #endif
 ],
-             [gl_cv_func_spawnattr_setschedpolicy=yes],
-             [gl_cv_func_spawnattr_setschedpolicy=no])
-          ])
-        dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDPARAM
-        dnl evaluates to nonzero.
-        dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedparam])
-        dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedparam])
-        AC_CACHE_CHECK([whether posix_spawnattr_setschedparam is supported],
-          [gl_cv_func_spawnattr_setschedparam],
-          [AC_EGREP_CPP([POSIX scheduling supported], [
+               [gl_cv_func_spawnattr_setschedpolicy=yes],
+               [gl_cv_func_spawnattr_setschedpolicy=no])
+            ])
+          dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDPARAM
+          dnl evaluates to nonzero.
+          dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedparam])
+          dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedparam])
+          AC_CACHE_CHECK([whether posix_spawnattr_setschedparam is supported],
+            [gl_cv_func_spawnattr_setschedparam],
+            [AC_EGREP_CPP([POSIX scheduling supported], [
 #include <spawn.h>
 #if POSIX_SPAWN_SETSCHEDPARAM
  POSIX scheduling supported
 #endif
 ],
-             [gl_cv_func_spawnattr_setschedparam=yes],
-             [gl_cv_func_spawnattr_setschedparam=no])
-          ])
-        ;;
-      *) REPLACE_POSIX_SPAWN=1 ;;
-    esac
+               [gl_cv_func_spawnattr_setschedparam=yes],
+               [gl_cv_func_spawnattr_setschedparam=no])
+            ])
+          ;;
+        *) REPLACE_POSIX_SPAWN=1 ;;
+      esac
+    fi
+  fi
+  if test $ac_cv_func_posix_spawn != yes || test $REPLACE_POSIX_SPAWN = 1; then
+    AC_DEFINE([REPLACE_POSIX_SPAWN], [1],
+      [Define if gnulib uses its own posix_spawn and posix_spawnp functions.])
   fi
 ])
 
diff --git a/m4/posix_spawn_faction_addchdir.m4 b/m4/posix_spawn_faction_addchdir.m4
new file mode 100644 (file)
index 0000000..ae3e03f
--- /dev/null
@@ -0,0 +1,20 @@
+# posix_spawn_faction_addchdir.m4 serial 1
+dnl Copyright (C) 2018 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_ADDCHDIR],
+[
+  AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
+  AC_REQUIRE([AC_PROG_CC])
+  gl_POSIX_SPAWN
+  AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addchdir posix_spawn_file_actions_addchdir_np])
+  if test $ac_cv_func_posix_spawn_file_actions_addchdir = yes; then
+    dnl This function is not yet standardized. Therefore override the
+    dnl system's implementation always.
+    REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=1
+  else
+    HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0
+  fi
+])
index 6cbdc4c9514f1e247267191f5d4682d45e7487bc..4862eef4da5f0c6bdd73d33e0c0187d820d0dbec 100644 (file)
@@ -1,4 +1,4 @@
-# spawn_h.m4 serial 16
+# spawn_h.m4 serial 17
 dnl Copyright (C) 2008-2018 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,7 @@ 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_adddup2 posix_spawn_file_actions_addchdir])
 ])
 
 dnl Checks whether the system has the functions posix_spawn.
@@ -92,6 +92,7 @@ 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])
@@ -115,7 +116,11 @@ AC_DEFUN([gl_SPAWN_H_DEFAULTS],
   HAVE_POSIX_SPAWNATTR_T=1;  AC_SUBST([HAVE_POSIX_SPAWNATTR_T])
   HAVE_POSIX_SPAWN_FILE_ACTIONS_T=1;
                              AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_T])
+  HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=1;
+                             AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
   REPLACE_POSIX_SPAWN=0;     AC_SUBST([REPLACE_POSIX_SPAWN])
+  REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0;
+                             AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
   REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0;
                              AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE])
   REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0;
diff --git a/modules/posix_spawn_file_actions_addchdir b/modules/posix_spawn_file_actions_addchdir
new file mode 100644 (file)
index 0000000..ad09334
--- /dev/null
@@ -0,0 +1,30 @@
+Description:
+posix_spawn_file_actions_addchdir() function: augment a child process actions
+specification.
+
+Files:
+lib/spawn_faction_addchdir.c
+lib/spawn_int.h
+m4/posix_spawn_faction_addchdir.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_ADDCHDIR = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = 1]
+
+configure.ac:
+gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR
+if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = 1; then
+  AC_LIBOBJ([spawn_faction_addchdir])
+fi
+gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_addchdir])
+
+Makefile.am:
+
+Include:
+<spawn.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
index 7a7a342817c4d136b5d525c9c156bc225e05e7af..27d6d8e1610481a43d905b96a194194e645b4e7d 100644 (file)
@@ -9,12 +9,12 @@ m4/posix_spawn.m4
 
 Depends-on:
 spawn
-getdtablesize                 [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = 1]
-posix_spawn_file_actions_init [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = 1]
+getdtablesize                 [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = 1]
+posix_spawn_file_actions_init [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = 1]
 
 configure.ac:
 gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE
-if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = 1; then
+if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = 1; then
   AC_LIBOBJ([spawn_faction_addclose])
 fi
 gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_addclose])
index df60b47f915361dc196c03f8943385580227736e..361ccb858ae87aa9feed1760553173ef9365b8e0 100644 (file)
@@ -9,12 +9,12 @@ m4/posix_spawn.m4
 
 Depends-on:
 spawn
-getdtablesize                 [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1]
-posix_spawn_file_actions_init [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1]
+getdtablesize                 [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1]
+posix_spawn_file_actions_init [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1]
 
 configure.ac:
 gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2
-if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1; then
+if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1; then
   AC_LIBOBJ([spawn_faction_adddup2])
 fi
 gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_adddup2])
index 50fd21ac4d47b09f169958f61e870113b196ac41..b4ee0da99cda3de38e0bbbc6f52aeb84de26d0c2 100644 (file)
@@ -9,12 +9,12 @@ m4/posix_spawn.m4
 
 Depends-on:
 spawn
-getdtablesize                 [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = 1]
-posix_spawn_file_actions_init [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = 1]
+getdtablesize                 [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = 1]
+posix_spawn_file_actions_init [test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = 1]
 
 configure.ac:
 gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN
-if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = 1; then
+if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = 1; then
   AC_LIBOBJ([spawn_faction_addopen])
 fi
 gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_addopen])
index 7a2af28b4ae897dc7b84d7c32fd22b1d382ec390..dc861d3f6f5b1ba4803a65718277abcd2f6a205e 100644 (file)
@@ -32,6 +32,7 @@ spawn.h: spawn.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
              -e 's/@''GNULIB_POSIX_SPAWN''@/$(GNULIB_POSIX_SPAWN)/g' \
              -e 's/@''GNULIB_POSIX_SPAWNP''@/$(GNULIB_POSIX_SPAWNP)/g' \
              -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT)/g' \
+             -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_ADDOPEN''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN)/g' \
@@ -53,7 +54,9 @@ spawn.h: spawn.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
              -e 's|@''HAVE_POSIX_SPAWN''@|$(HAVE_POSIX_SPAWN)|g' \
              -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|@''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_ADDOPEN''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN)|g' \
index a822a185869e89ac908bb2b4784f67e19938eafa..04b7aa3363a9042f97412f39df0507d4e5c75eb0 100644 (file)
@@ -132,6 +132,11 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::posix_spawn_file_actions_adddup2, int,
                  (posix_spawn_file_actions_t *, int, int));
 #endif
 
+#if GNULIB_TEST_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR
+SIGNATURE_CHECK (GNULIB_NAMESPACE::posix_spawn_file_actions_addchdir, int,
+                 (posix_spawn_file_actions_t *, const char *));
+#endif
+
 
 int
 main ()