posix_spawn_file_actions_init()

Initialize a spawn file actions object

Synopsis:

#include <spawn.h>

int posix_spawn_file_actions_init(
       posix_spawn_file_actions_t *fact_p);

Arguments:

fact_p
A pointer to the spawn file action object that you want to initialize.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The posix_spawn_file_actions_init() function initializes the object referenced by fact_p to contain no file actions for posix_spawn() or posix_spawnp() to perform. For information about destroying a spawn file actions object, see posix_spawn_file_actions_destroy() .

A spawn file actions object is an opaque data type that specifies a series of actions to be performed by a posix_spawn() or posix_spawnp() operation in order to arrive at the set of open file descriptors for the child process, given the set of open file descriptors of the parent.

When passed to posix_spawn() or posix_spawnp(), a spawn file actions object specifies how the set of open file descriptors in the calling process is transformed into a set of potentially open file descriptors for the spawned process. This transformation occurs as if the specified sequence of actions were performed exactly once, in the context of the spawned process (prior to execution of the new process image), in the order in which the actions were added to the object. Additionally, when the new process image is executed, any file descriptor (from this new set) that has its FD_CLOEXEC flag set will be closed (see posix_spawn() ).

A spawn file actions object may be initialized to contain an ordered sequence of close(), dup2(), and open() operations used by posix_spawn() or posix_spawnp() to arrive at the set of open file descriptors inherited by the spawned process from the set of open file descriptors in the parent at the time of the posix_spawn() or posix_spawnp() call.

Don't reinitialize a posix_spawn_file_actions_t object without destroying it. Repeated calls to posix_spawn_file_actions_init() with the same posix_spawn_file_actions_t object could result in a memory leak. In the QNX Neutrino implementation, all get and set operations, as well as posix_spawn(), return EINVAL when attempting to reference a destroyed file actions object.

Returns:

EOK
Success.
EINVAL
An argument was invalid.
ENOMEM
Insufficient memory exists to initialize the spawn file actions object.

Classification:

POSIX 1003.1 SPN

Safety:
Cancellation point No
Interrupt handler Yes
Signal handler Yes
Thread Yes