Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

posix_spawn_file_actions_adddup2()

Add the dup2() action to spawn file actions object

Synopsis:

#include <posix_spawn_file_actions.h>

int posix_spawn_file_actions_adddup2(
       posix_spawn_file_actions_t *fact_p,
       int fd,
       int new_fd);

Arguments:

fact_p
The file action to update the spawn file actions object.
fd
The file descriptors in the array.
new_fd
The file descriptor fd that was duplicated.

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_adddup2() function adds a dup2() action to the object referenced by fact_p that causes the file descriptor fd to be duplicated as new_fd (as if dup2(fd, new_fd) had been called) when a new process is spawned using this file actions object. A spawn file actions object is as defined in posix_spawn_file_actions_addclose().

Returns:

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

Errors:

EBADF
The value specified by fildes or newfildes is negative or greater than or equal to {OPEN_MAX}.
EINVAL
For any invalid parameter. The value specified by file_actions is invalid. It will not be considered an error for the fd argument passed to the posix_spawn_file_actions_adddup2() function to specify a file descriptor 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.
ENOMEM
If the action couldn't be added to the file actions object, or insufficient memory exists to add to the spawn file actions object.
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_addopen(), 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()