posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
_POSIX_SPAWN

POSIX Spawn option. More...

Files

file  spawn.h
 POSIX process spawning (<spawn.h>)
 

Data Structures

struct  posix_spawnattr_t
 Spawn attributes object, initialized with posix_spawnattr_init(). More...
 
struct  posix_spawn_file_actions_t
 Ordered list of file actions performed in the child, initialized with posix_spawn_file_actions_init(). More...
 

Macros

#define POSIX_SPAWN_RESETIDS   0x01
 Reset the child's effective user and group IDs to its real IDs.
 
#define POSIX_SPAWN_SETPGROUP   0x02
 Place the child in the process group named by the pgroup attribute.
 
#define POSIX_SPAWN_SETSCHEDPARAM   0x04
 Set the child's scheduling parameters from the schedparam attribute.
 
#define POSIX_SPAWN_SETSCHEDULER   0x08
 Set the child's scheduling policy from the schedpolicy attribute.
 
#define POSIX_SPAWN_SETSIGDEF   0x10
 Reset the signals named by the sigdefault attribute to their default actions.
 
#define POSIX_SPAWN_SETSIGMASK   0x20
 Set the child's signal mask from the sigmask attribute.
 

Functions

int posix_spawn (pid_t *pid, const char *path, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *attrp, char *const argv[], char *const envp[])
 Spawn a new process from the executable image named by path.
 
int posix_spawnp (pid_t *pid, const char *file, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *attrp, char *const argv[], char *const envp[])
 Spawn a new process, resolving file as posix_spawn() resolves a path.
 
int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *file_actions, int fildes)
 Add a close action for descriptor fildes in the child.
 
int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *file_actions, int fildes, int newfildes)
 Add a dup2 action in the child, duplicating fildes onto newfildes.
 
int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *file_actions, int fildes, const char *path, int oflag, mode_t mode)
 Add an open action in the child, opening path as descriptor fildes.
 
int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *file_actions)
 Destroy a file actions object.
 
int posix_spawn_file_actions_init (posix_spawn_file_actions_t *file_actions)
 Initialize a file actions object with no actions.
 
int posix_spawnattr_destroy (posix_spawnattr_t *attr)
 Destroy a spawn attributes object.
 
int posix_spawnattr_getflags (const posix_spawnattr_t *attr, short *flags)
 Get the POSIX_SPAWN_* flags of a spawn attributes object.
 
int posix_spawnattr_getpgroup (const posix_spawnattr_t *attr, pid_t *pgroup)
 Get the process group attribute.
 
int posix_spawnattr_getschedparam (const posix_spawnattr_t *attr, struct sched_param *schedparam)
 Get the scheduling parameter attribute.
 
int posix_spawnattr_getschedpolicy (const posix_spawnattr_t *attr, int *schedpolicy)
 Get the scheduling policy attribute.
 
int posix_spawnattr_getsigdefault (const posix_spawnattr_t *attr, sigset_t *sigdefault)
 Get the default-signals attribute.
 
int posix_spawnattr_getsigmask (const posix_spawnattr_t *attr, sigset_t *sigmask)
 Get the signal mask attribute.
 
int posix_spawnattr_init (posix_spawnattr_t *attr)
 Initialize a spawn attributes object with default values.
 
int posix_spawnattr_setflags (posix_spawnattr_t *attr, short flags)
 Set the POSIX_SPAWN_* flags of a spawn attributes object.
 
int posix_spawnattr_setpgroup (posix_spawnattr_t *attr, pid_t pgroup)
 Set the process group attribute, applied with POSIX_SPAWN_SETPGROUP.
 
int posix_spawnattr_setschedparam (posix_spawnattr_t *attr, const struct sched_param *schedparam)
 Set the scheduling parameter attribute, applied with POSIX_SPAWN_SETSCHEDPARAM.
 
int posix_spawnattr_setschedpolicy (posix_spawnattr_t *attr, int schedpolicy)
 Set the scheduling policy attribute, applied with POSIX_SPAWN_SETSCHEDULER.
 
int posix_spawnattr_setsigdefault (posix_spawnattr_t *attr, const sigset_t *sigdefault)
 Set the default-signals attribute, applied with POSIX_SPAWN_SETSIGDEF.
 
int posix_spawnattr_setsigmask (posix_spawnattr_t *attr, const sigset_t *sigmask)
 Set the signal mask attribute, applied with POSIX_SPAWN_SETSIGMASK.
 

Detailed Description

POSIX Spawn option.

Macro Definition Documentation

◆ POSIX_SPAWN_RESETIDS

#define POSIX_SPAWN_RESETIDS   0x01

Reset the child's effective user and group IDs to its real IDs.

Definition at line 36 of file spawn.h.

◆ POSIX_SPAWN_SETPGROUP

#define POSIX_SPAWN_SETPGROUP   0x02

Place the child in the process group named by the pgroup attribute.

Definition at line 41 of file spawn.h.

◆ POSIX_SPAWN_SETSCHEDPARAM

#define POSIX_SPAWN_SETSCHEDPARAM   0x04

Set the child's scheduling parameters from the schedparam attribute.

Definition at line 46 of file spawn.h.

◆ POSIX_SPAWN_SETSCHEDULER

#define POSIX_SPAWN_SETSCHEDULER   0x08

Set the child's scheduling policy from the schedpolicy attribute.

Definition at line 51 of file spawn.h.

◆ POSIX_SPAWN_SETSIGDEF

#define POSIX_SPAWN_SETSIGDEF   0x10

Reset the signals named by the sigdefault attribute to their default actions.

Definition at line 56 of file spawn.h.

◆ POSIX_SPAWN_SETSIGMASK

#define POSIX_SPAWN_SETSIGMASK   0x20

Set the child's signal mask from the sigmask attribute.

Definition at line 61 of file spawn.h.

Function Documentation

◆ posix_spawn()

int posix_spawn ( pid_t pid,
const char *  path,
const posix_spawn_file_actions_t file_actions,
const posix_spawnattr_t attrp,
char *const  argv[],
char *const  envp[] 
)

Spawn a new process from the executable image named by path.

File actions and attributes are applied in the child, in that order, before the child begins execution.

Parameters
pidOutput: process ID of the child, or NULL.
pathPath naming the executable image.
file_actionsFile actions performed in the child, or NULL.
attrpSpawn attributes, or NULL for defaults.
argvNULL-terminated argument vector for the child.
envpNULL-terminated environment vector for the child.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html

◆ posix_spawn_file_actions_addclose()

int posix_spawn_file_actions_addclose ( posix_spawn_file_actions_t file_actions,
int  fildes 
)

Add a close action for descriptor fildes in the child.

Parameters
file_actionsFile actions object.
fildesDescriptor to close in the child.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_addclose.html

◆ posix_spawn_file_actions_adddup2()

int posix_spawn_file_actions_adddup2 ( posix_spawn_file_actions_t file_actions,
int  fildes,
int  newfildes 
)

Add a dup2 action in the child, duplicating fildes onto newfildes.

Parameters
file_actionsFile actions object.
fildesSource descriptor.
newfildesDestination descriptor in the child.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_adddup2.html

◆ posix_spawn_file_actions_addopen()

int posix_spawn_file_actions_addopen ( posix_spawn_file_actions_t file_actions,
int  fildes,
const char *  path,
int  oflag,
mode_t  mode 
)

Add an open action in the child, opening path as descriptor fildes.

Parameters
file_actionsFile actions object.
fildesDescriptor to open in the child.
pathPath to open.
oflagOpen flags, as for open().
modeCreation mode, as for open().
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_addopen.html

◆ posix_spawn_file_actions_destroy()

int posix_spawn_file_actions_destroy ( posix_spawn_file_actions_t file_actions)

Destroy a file actions object.

Parameters
file_actionsFile actions object.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_destroy.html

◆ posix_spawn_file_actions_init()

int posix_spawn_file_actions_init ( posix_spawn_file_actions_t file_actions)

Initialize a file actions object with no actions.

Parameters
file_actionsFile actions object.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_init.html

◆ posix_spawnattr_destroy()

int posix_spawnattr_destroy ( posix_spawnattr_t attr)

Destroy a spawn attributes object.

Parameters
attrSpawn attributes object.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_destroy.html

◆ posix_spawnattr_getflags()

int posix_spawnattr_getflags ( const posix_spawnattr_t attr,
short *  flags 
)

Get the POSIX_SPAWN_* flags of a spawn attributes object.

Parameters
attrSpawn attributes object.
flagsOutput: current flags.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getflags.html

◆ posix_spawnattr_getpgroup()

int posix_spawnattr_getpgroup ( const posix_spawnattr_t attr,
pid_t pgroup 
)

Get the process group attribute.

Parameters
attrSpawn attributes object.
pgroupOutput: current process group attribute.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getpgroup.html

◆ posix_spawnattr_getschedparam()

int posix_spawnattr_getschedparam ( const posix_spawnattr_t attr,
struct sched_param *  schedparam 
)

Get the scheduling parameter attribute.

Parameters
attrSpawn attributes object.
schedparamOutput: current scheduling parameters.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getschedparam.html

◆ posix_spawnattr_getschedpolicy()

int posix_spawnattr_getschedpolicy ( const posix_spawnattr_t attr,
int *  schedpolicy 
)

Get the scheduling policy attribute.

Parameters
attrSpawn attributes object.
schedpolicyOutput: current scheduling policy.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getschedpolicy.html

◆ posix_spawnattr_getsigdefault()

int posix_spawnattr_getsigdefault ( const posix_spawnattr_t attr,
sigset_t sigdefault 
)

Get the default-signals attribute.

Parameters
attrSpawn attributes object.
sigdefaultOutput: signals reset to their default actions in the child.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getsigdefault.html

◆ posix_spawnattr_getsigmask()

int posix_spawnattr_getsigmask ( const posix_spawnattr_t attr,
sigset_t sigmask 
)

Get the signal mask attribute.

Parameters
attrSpawn attributes object.
sigmaskOutput: signal mask applied to the child.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getsigmask.html

◆ posix_spawnattr_init()

int posix_spawnattr_init ( posix_spawnattr_t attr)

Initialize a spawn attributes object with default values.

Parameters
attrSpawn attributes object.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_init.html

◆ posix_spawnattr_setflags()

int posix_spawnattr_setflags ( posix_spawnattr_t attr,
short  flags 
)

Set the POSIX_SPAWN_* flags of a spawn attributes object.

Parameters
attrSpawn attributes object.
flagsNew flags.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setflags.html

◆ posix_spawnattr_setpgroup()

int posix_spawnattr_setpgroup ( posix_spawnattr_t attr,
pid_t  pgroup 
)

Set the process group attribute, applied with POSIX_SPAWN_SETPGROUP.

Parameters
attrSpawn attributes object.
pgroupProcess group for the child; 0 starts a new group led by the child.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setpgroup.html

◆ posix_spawnattr_setschedparam()

int posix_spawnattr_setschedparam ( posix_spawnattr_t attr,
const struct sched_param *  schedparam 
)

Set the scheduling parameter attribute, applied with POSIX_SPAWN_SETSCHEDPARAM.

Parameters
attrSpawn attributes object.
schedparamScheduling parameters for the child.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setschedparam.html

◆ posix_spawnattr_setschedpolicy()

int posix_spawnattr_setschedpolicy ( posix_spawnattr_t attr,
int  schedpolicy 
)

Set the scheduling policy attribute, applied with POSIX_SPAWN_SETSCHEDULER.

Parameters
attrSpawn attributes object.
schedpolicyScheduling policy for the child.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setschedpolicy.html

◆ posix_spawnattr_setsigdefault()

int posix_spawnattr_setsigdefault ( posix_spawnattr_t attr,
const sigset_t sigdefault 
)

Set the default-signals attribute, applied with POSIX_SPAWN_SETSIGDEF.

Parameters
attrSpawn attributes object.
sigdefaultSignals reset to their default actions in the child.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setsigdefault.html

◆ posix_spawnattr_setsigmask()

int posix_spawnattr_setsigmask ( posix_spawnattr_t attr,
const sigset_t sigmask 
)

Set the signal mask attribute, applied with POSIX_SPAWN_SETSIGMASK.

Parameters
attrSpawn attributes object.
sigmaskSignal mask for the child.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setsigmask.html

◆ posix_spawnp()

int posix_spawnp ( pid_t pid,
const char *  file,
const posix_spawn_file_actions_t file_actions,
const posix_spawnattr_t attrp,
char *const  argv[],
char *const  envp[] 
)

Spawn a new process, resolving file as posix_spawn() resolves a path.

Parameters
pidOutput: process ID of the child, or NULL.
fileName of the executable image.
file_actionsFile actions performed in the child, or NULL.
attrpSpawn attributes, or NULL for defaults.
argvNULL-terminated argument vector for the child.
envpNULL-terminated environment vector for the child.
Returns
0 on success, or an errno value on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnp.html