]> Savannah Git Hosting - gnulib.git/commitdiff
posix_spawn_file_actions_addfchdir: New module.
authorBruno Haible <bruno@clisp.org>
Mon, 10 Jun 2019 14:16:16 +0000 (16:16 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 10 Jun 2019 14:29:44 +0000 (16:29 +0200)
* 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.

14 files changed:
ChangeLog
doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi
doc/posix-functions/posix_spawn.texi
doc/posix-functions/posix_spawnp.texi
lib/spawn.in.h
lib/spawn_faction_addfchdir.c [new file with mode: 0644]
lib/spawn_int.h
lib/spawni.c
m4/posix_spawn.m4
m4/posix_spawn_faction_addfchdir.m4 [new file with mode: 0644]
m4/spawn_h.m4
modules/posix_spawn_file_actions_addfchdir [new file with mode: 0644]
modules/spawn
tests/test-spawn-c++.cc

index ac79aaca9ce8aaaedf84eba4883cad74d69dd666..ecf1d47fe19b502101703eba913a7d5fc90255d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+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.
index bb821953373cd53a036e64a6a7ce4bc600868a82..6da90fd9d96d26ae80a50ccdc1b673eb4558ce81 100644 (file)
@@ -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}.
index bed0e794901d67ecd3af94c9fe688a0f3fd194cc..651360885d1d5fdf4ddcdbcf6adb97862661c111 100644 (file)
@@ -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.
index 6cfec28dc60b28d013dec6485c3b4519268bb38d..3dd8ed4cc28e91d7007e5c1b2077147a3910876e 100644 (file)
@@ -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.
index df95e4a6205e6f0cfdf5cc23198632639886ac13..721d70f4b03e037ec147480b7e6583dbc0c7d904 100644 (file)
@@ -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 (file)
index 0000000..504856d
--- /dev/null
@@ -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
+}
index 06b8004c8feb001e5a594eaec319318462dda178..584c1bbcc3f8bf9372ffb2b60c9790d3ce110b99 100644 (file)
@@ -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;
 };
 
index 39e99a0b43f2eec5758fca50761b7edbba691aab..087f45c9c3fb60123dc1023c1dd9bb4cab6fc48e 100644 (file)
@@ -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;
             }
         }
     }
index d50dcc9e2a7d94e38fa73cd4b21928582252e6d4..0128390d468cd975eb9c0958ce85afa6c531264f 100644 (file)
@@ -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 (file)
index 0000000..ef2f9d6
--- /dev/null
@@ -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
+])
index 561caa77454d476f2c75b16b2cc5814d298a8fa7..95cb25d284ca262c3d03b0fb9d957c1714672031 100644 (file)
@@ -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 (file)
index 0000000..cd9cb99
--- /dev/null
@@ -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
index dc861d3f6f5b1ba4803a65718277abcd2f6a205e..6e032943d12bff1827f09a5c70c37923b325508a 100644 (file)
@@ -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)' \
index 2ba1cc4bb30a1876fab2f5ce32a720cc0ca52a42..119917ffed8edafd6f811981be77453e6548cea7 100644 (file)
@@ -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 ()