posix_spawn_file_actions_addclose(), posix_spawn_file_actions_addopen()

add close or open action to spawn file actions object 

Advanced Realtime Function


SYNOPSIS

#include <spawn.h>

int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *file_actions, int fildes);

int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict file_actions, int fildes, const char *restrict path, int oflag, mode_tmode);


DESCRIPTION

The posix_spawn_file_actions_addclose() posix_spawn_file_actions_addopen() functions add or delete a close or open action to a spawn file actions object.

Both of these functions use a spawn file actions object of type posix_spawn_file_actions_t (defined in <spawn.h>) to specify the actions that posix_spawn() or posix_spawnp() should perform to generate the open file descriptors for the child process from the open file descriptors of the parent. These actions are performed in the order the actions are added to the object.

The posix_spawn_file_actions_addclose() function adds a close action to the file_actions object. This action causes the specified file descriptor fildes to be closed (as if close(fildes) had been called) when posix_spawn() or posix_spawnp() spawns a new process using this file actions object.

The posix_spawn_file_actions_addopen() function adds an open action to the file_actions object. This action causes the file named by path to be opened (as if open(path, oflag, mode) had been called, and the returned file descriptor, if not fildes, had been changed to fildes) when posix_spawn() or posix_spawnp() spawns a new process using this file actions object. When fildes is already an open file descriptor, it is closed before the new file is opened.

The posix_file_actions_addopen() copies the string described by path.


PARAMETERS

fildes 

Specifies a file descriptor,

file_actions 

Points to a spawn file actions object.

mode 

Specifies the permissions to be assigned when a new file is opened using the added open action. This is the same as the mode argument for the open() function.

oflag 

Specifies the bitwise inclusive-OR of the file access modes and file status flags to be used when a new file is opened using the added open action. This is the same as the oflag argument for the open() function.

path 

Specifies the path name of the file to be opened using the added open action. This is the same as the pathname argument for the open() function.


RETURN VALUES

When completed successfully, the posix_spawn() and posix_spawnp() functions return 0. Otherwise, these function return one of the following error numbers to indicate the error.

EBADF 

The fildes argument is negative or it is greater than or equal to {OPEN_MAX}.

EINVAL 

The file_actions argument contains an invalid value.

ENOMEM 

There is not enough memory to add to the spawn file actions object.

Note:

It is not considered an error when fildes specifies a file descriptor for which the specified operation could not be performed at the time of the call. Such an error is, however, detected when the file actions object is later used in a posix_spawn() or posix_spawnp() function call.


CONFORMANCE

UNIX 03.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
close(), dup(), open(), posix_spawn(), posix_spawn_file_actions_adddup2(), posix_spawn_file_actions_destroy(), posix_spawnp()

Miscellaneous:
spawn


PTC MKS Toolkit 10.5 Documentation Build 40.