posix_spawn_file_actions_addclose()

Add a “close a file descriptor” action to a spawn file actions object

Synopsis:

#include <spawn.h>

int posix_spawn_file_actions_addclose(
       posix_spawn_file_actions_t *fact_p,
       int fd);

Arguments:

fact_p
A pointer to the spawn file actions object that you want to update. You must have already initialized this object by calling posix_spawn_file_actions_init().
fd
The file descriptor that you want to close when the child process starts.

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_addclose() function adds a close action to a spawn file actions object (the object referenced by fact_p) that causes the file descriptor fd to be closed (as if close(fd) had been called) when a new process is spawned using this file actions object.

Returns:

EOK
Success.
EBADF
The fd argument is negative or greater than {OPEN_MAX}.
EINVAL
The value specified by fact_p is invalid.
ENOMEM
The action couldn't be added to the file actions object, or insufficient memory exists to add to the spawn file actions object.

It isn't considered an error if the fd argument specifies 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.

Classification:

POSIX 1003.1 SPN

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