posix_spawn_file_actions_addchdir_np, posix_spawn_file_actions_addchdir, posix_spawn_file_actions_addfchdir - add chdir action to spawn file actions object
#include <spawn.h> int posix_spawn_file_actions_addchdir_np( posix_spawn_file_actions_t *restrict file_actions, const char *restrict path);
int posix_spawn_file_actions_addchdir( posix_spawn_file_actions_t *restrict file_actions, const char *restrict path);
int posix_spawn_file_actions_addfchdir( posix_spawn_file_actions_t *restrict file_actions, int filedes);
The posix_spawn_file_actions_addchdir_np(), posix_spawn_file_actions_addchdir() and posix_spawn_file_actions_addfchdir() functions adds a chdir action to to the object referenced by file_actions. This causes a new process that is spawned using this file actions object to change its working directory to path (see chdir(2)) or filedes (see fchdir(2)). The fildes argument is an open file descriptor of a directory.
A spawn file actions object is as defined in posix_spawn_file_actions_addclose(3C).
File actions are performed in a new process created by posix_spawn() or posix_spawnp() in the same order that they were added to the file actions object. Thus, the execution of an addopen action that was created by a call to posix_spawn_file_actions_addopen() that specifies a relative path will be affected by the execution of a chdir action that was created by a previous call to posix_spawn_file_actions_addchdir_np(). Likewise, a relative path passed to posix_spawn() is affected by the last chdir action in the file action list.
The string described by path is copied by the posix_spawn_file_actions_addchdir_np() function.
Upon successful completion, posix_spawn_file_actions_addchdir_np() returns 0. Otherwise, an error number is returned to indicate the error.
The posix_spawn_file_actions_addchdir_np() function may fail if:
The value specified by file_actions is invalid.
Insufficient memory exists to add to the spawn file actions object.
It is not considered an error for the path argument passed to posix_spawn_file_actions_addchdir_np() to specify a path for which the specified operation could not be performed at the time of the call. Any such error will be detected when the associated file actions object is later used during a posix_spawn() or posix_spawnp() operation.
See attributes(7) for descriptions of the following attributes:
chdir(2), open(2), posix_spawn(3C), posix_spawn_file_actions_addclose(3C), posix_spawn_file_actions_addopen(3C), posix_spawn_file_actions_destroy(3C), spawn.h(3HEAD), attributes(7), standards(7)