posix_spawn_file_actions_addopen()

Add an open action to the object referenced that causes the file named by the path to be opened

Synopsis:

#include <posix_spawn_file_actions.h>

int posix_spawn_file_actions_addopen(
       posix_spawn_file_actions_t *_Restrict fact_p,
       int new_fd,
       const char *_Restrict path,
       int oflags,
       mode_t omode);

Arguments:

fact_p
The file action to update the spawn file actions object.
new_fd
The updated file descriptors count.
path
The name of the file to open. The string described by path is copied by the posix_spawn_file_actions_addopen() function.
oflags
Flags that specify the status and access modes of the file.
omode
An object of type mode_t that specifies the access mode to use for a newly created file. For more information, see “Access permissions” and O_CREATE in the documentation for stat().

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_addopen() function will add an open action to the object referenced by fact_p that will cause the file named by path to be opened (as if open(path, oflag, mode) had been called, and the returned file descriptor, if not fd, had been changed to fd) when a new process is spawned using this file actions object. If fd was already an open file descriptor, it will be closed before the new file is opened.

For detailed information about the open and close functions, see posix_spawn_file_actions_addopen() and posix_spawn_file_actions_addclose() functions.

Returns:

Upon successful completion, these functions returns zero; otherwise, an error number is returned to indicate the error (errno is set).

Errors:

EBADF
The value specified by new_fd is negative or greater than or equal to {OPEN_MAX}.
EINVAL
For any invalid parameter, or the value specified by fact_p is invalid.
ENOMEM
The partition ID couldn't be added to the attributes object, or insufficient memory exists to add to the spawn file actions object. It isn't considered an error if the new_fd argument is passed to these functions to specify a file descriptor for which the specified operation couldn't be performed at the time of the call. This type of error isn't detected when the associated file actions object is later used during a posix_spawn() or posix_spawnp() operation.
EOK
Success.

Classification:

POSIX 1003.1 RTS

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

See also:

posix_spawn(), posix_spawn_file_actions_addclose(), posix_spawn_file_actions_adddup2(), posix_spawn_file_actions_destroy(), posix_spawn_file_actions_init(), posix_spawnattr_addpartid(), posix_spawnattr_addpartition(), posix_spawnattr_destroy(), posix_spawnattr_getcred(), posix_spawnattr_getflags(), posix_spawnattr_getnode(), posix_spawnattr_getpartid(), posix_spawnattr_getpgroup(), posix_spawnattr_getrunmask(), posix_spawnattr_getschedparam(), posix_spawnattr_getschedpolicy(), posix_spawnattr_getsigdefault(), posix_spawnattr_getsigignore(), posix_spawnattr_getsigmask(), posix_spawnattr_getstackmax(), posix_spawnattr_getxflags(), posix_spawnattr_init(), posix_spawnattr_setcred(), posix_spawnattr_setflags(), posix_spawnattr_setnode(), posix_spawnattr_setpgroup(), posix_spawnattr_setschedparam(), posix_spawnattr_setrunmask(), posix_spawnattr_setschedpolicy(), posix_spawnattr_setsigdefault(), posix_spawnattr_setsigignore(), posix_spawnattr_setsigmask(), posix_spawnattr_setstackmax(), posix_spawnattr_setxflags(), posix_spawnp()