posix_spawnattr_destroy or posix_spawnattr_init Subroutine

Purpose

Destroys and initializes a spawn attributes object.

Syntax

#include <spawn.h>

int posix_spawnattr_destroy(posix_spawnattr_t *attr);
int posix_spawnattr_init(posix_spawnattr_t *attr); 

Description

The posix_spawnattr_destroy subroutine destroys a spawn attributes object. A destroyed attr attributes object can be reinitialized using posix_spawnattr_init; the results of otherwise referencing the object after it has been destroyed are undefined. An implementation can cause posix_spawnattr_destroy to set the object referenced by attr to an invalid value.

The posix_spawnattr_init subroutine initializes a spawn attributes object attr with the default value for all of the individual attributes used by the implementation. Results are undefined if posix_spawnattr_init is called specifying an attr attributes object that is already initialized.

A spawn attributes object is of type posix_spawnattr_t (defined in the spawn.h header file) and is used to specify the inheritance of process attributes across a spawn operation. Comparison or assignment operators for the type posix_spawnattr_t are not defined.

Each implementation documents the individual attributes it uses and their default values unless these values are defined by IEEE Std 1003.1-2001. Attributes not defined by IEEE Std 1003.1-2001, their default values, and the names of the associated functions to get and set those attribute values are implementation-defined.

The resulting spawn attributes object (possibly modified by setting individual attribute values), is used to modify the behavior of posix_spawn or posix_spawnp. After a spawn attributes object has been used to spawn a process by a call to a posix_spawn or posix_spawnp, any function affecting the attributes object (including destruction) will not affect any process that has been spawned in this way.

Return Values

Upon successful completion, the posix_spawnattr_destroy and posix_spawnattr_init subroutines return 0; otherwise, an error number is returned to indicate the error.

Error Codes

The posix_spawnattr_destroy subroutine might fail if the following is true:
Item Description
EINVAL The value specified by attr is invalid.