The QNX Neutrino spawn()
function is similar to posix_spawn().
The spawn() function gives you control over
the following:
- file descriptors
- process group ID
- signal mask
- ignored signals
- the node to create the process on
- scheduling policy
- scheduling parameters (priority)
- maximum stack size
- runmask (for SMP systems)
The basic forms of the
spawn()
function are:
- spawn()
- Spawn with the explicitly specified path.
- spawnp()
- Search the current PATH and invoke spawn()
with the first matching executable.
There's also a set of convenience functions that are built
on top of spawn() and spawnp() as follows:
- spawnl()
- Spawn with the command line provided as inline arguments.
- spawnle()
- spawnl() with explicitly passed environment variables.
- spawnlp()
- spawnp() that follows the command search path.
- spawnlpe()
- spawnlp() with explicitly passed environment variables.
- spawnv()
- Spawn with the command line pointed to by an array of pointers.
- spawnve()
- spawnv() with explicitly passed environment variables.
- spawnvp()
- spawnv() that follows the command search path.
- spawnvpe()
- spawnvp() with explicitly passed environment variables.
When a process is spawn()'ed, the child process inherits the following attributes of its
parent:
- process group ID (unless SPAWN_SETGROUP is set in inherit.flags)
- session membership
- real user ID and real group ID
- supplementary group IDs
- priority and scheduling policy
- current working directory and root directory
- file creation mask
- signal mask (unless SPAWN_SETSIGMASK is set in inherit.flags)
- signal actions specified as SIG_DFL
- signal actions specified as SIG_IGN (except the
ones modified by inherit.sigdefault when
SPAWN_SETSIGDEF is set in inherit.flags)
The child process has several differences from the parent process:
- Signals set to be caught by the parent process are set to the
default action (SIG_DFL).
- The child process's tms_utime, tms_stime,
tms_cutime, and tms_cstime are tracked separately
from the parent's.
- The number of seconds left until a SIGALRM signal
would be generated is set to zero for the child process.
- The set of pending signals for the child process is empty.
- File locks set by the parent aren't inherited.
- Per-process timers created by the parent aren't inherited.
- Memory locks and mappings set by the parent aren't inherited.
If the child process is spawned on a remote node, the process group ID and
the session membership aren't set;
the child process is put into a new session and a new process group.
The child process can access the parent process's environment by using the
environ
global variable (found in <unistd.h>).
For more information, see the
spawn()
function in the QNX Neutrino C Library Reference.