posix_spawnattr_getflags or posix_spawnattr_setflags Subroutine

Purpose

Gets and sets the spawn-flags attribute of a spawn attributes object.

Syntax

#include <spawn.h>

int posix_spawnattr_getflags(const posix_spawnattr_t *restrict attr,
       short *restrict flags);
int posix_spawnattr_setflags(posix_spawnattr_t *attr, short flags);

Description

The posix_spawnattr_getflags subroutine obtains the value of the spawn-flags attribute from the attributes object referenced by attr. The posix_spawnattr_setflags subroutine sets the spawn-flags attribute in an initialized attributes object referenced by attr. The spawn-flags attribute is used to indicate which process attributes are to be changed in the new process image when invoking posix_spawn or posix_spawnp. It is the bitwise-inclusive OR of 0 or more of the following flags:
  • POSIX_SPAWN_RESETIDS
  • POSIX_SPAWN_SETPGROUP
  • POSIX_SPAWN_SETSIGDEF
  • POSIX_SPAWN_SETSIGMASK
  • POSIX_SPAWN_SETSCHEDPARAM
  • POSIX_SPAWN_SETSCHEDULER
These flags are defined in the spawn.h header file. The default value of this attribute is as if no flags were set.

Return Values

Upon successful completion, the posix_spawnattr_getflags subroutine returns 0 and stores the value of the spawn-flags attribute of attr into the object referenced by the flags parameter; otherwise, an error number is returned to indicate the error.

Upon successful completion, the posix_spawnattr_setflags subroutine returns 0; otherwise, an error number is returned to indicate the error.

Error Codes

The posix_spawnattr_getflags and posix_spawnattr_setflags subroutines will fail if the following is true:
Item Description
EINVAL The value specified by attr is invalid.
The posix_spawnattr_setflags subroutine might fail if the following is true:
Item Description
EINVAL The value of the attribute being set is not valid.