summaryrefslogtreecommitdiff
path: root/lib/spawn.in.h
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2018-09-07 23:35:52 +0200
committerBruno Haible <bruno@clisp.org>2018-09-07 23:37:01 +0200
commit86b1dc8935e627c14f5d5f3141fbcc2ca7e900a3 (patch)
tree30988e12f51872e8d9c98e24eaacab5510a45732 /lib/spawn.in.h
parente41da81043a9e191ff8e45c24af71b3bbc749ef6 (diff)
downloadgnulib-86b1dc8935e627c14f5d5f3141fbcc2ca7e900a3.tar.gz
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.
Diffstat (limited to 'lib/spawn.in.h')
-rw-r--r--lib/spawn.in.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/spawn.in.h b/lib/spawn.in.h
index a606176523..7460c651b6 100644
--- a/lib/spawn.in.h
+++ b/lib/spawn.in.h
@@ -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 */