comparison lib/spawn_faction_addclose.c @ 39828:8d755c31408d

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.
author Bruno Haible <bruno@clisp.org>
date Fri, 07 Sep 2018 23:35:52 +0200
parents 10eb9086bea0
children b06060465f09
comparison
equal deleted inserted replaced
39827:96fe1f932130 39828:8d755c31408d
24 24
25 #if !_LIBC 25 #if !_LIBC
26 # define __sysconf(open_max) getdtablesize () 26 # define __sysconf(open_max) getdtablesize ()
27 #endif 27 #endif
28 28
29 #if !HAVE_WORKING_POSIX_SPAWN 29 #if REPLACE_POSIX_SPAWN
30 # include "spawn_int.h" 30 # include "spawn_int.h"
31 #endif 31 #endif
32 32
33 /* Add an action to FILE-ACTIONS which tells the implementation to call 33 /* Add an action to FILE-ACTIONS which tells the implementation to call
34 'close' for the given file descriptor during the 'spawn' call. */ 34 'close' for the given file descriptor during the 'spawn' call. */
41 41
42 /* Test for the validity of the file descriptor. */ 42 /* Test for the validity of the file descriptor. */
43 if (fd < 0 || fd >= maxfd) 43 if (fd < 0 || fd >= maxfd)
44 return EBADF; 44 return EBADF;
45 45
46 #if HAVE_WORKING_POSIX_SPAWN 46 #if !REPLACE_POSIX_SPAWN
47 return posix_spawn_file_actions_addclose (file_actions, fd); 47 return posix_spawn_file_actions_addclose (file_actions, fd);
48 #else 48 #else
49 /* Allocate more memory if needed. */ 49 /* Allocate more memory if needed. */
50 if (file_actions->_used == file_actions->_allocated 50 if (file_actions->_used == file_actions->_allocated
51 && __posix_spawn_file_actions_realloc (file_actions) != 0) 51 && __posix_spawn_file_actions_realloc (file_actions) != 0)