Detailed comparison of fork()+execve() vs posix_spawn (QNX-only)#
Property (config) |
fork() + execve() (current) |
posix_spawn() (QNX, new) |
Difference |
|---|---|---|---|
Executable / argv ( |
|
|
Same result. Exec errors ( |
Environment ( |
|
|
None |
Comms fd ( |
Child: |
File action |
Same result. Native processes get no comms fd in either case |
Process group (implicit) |
Child: |
|
Same result |
Signal dispositions / mask (implicit) |
Child: |
|
Same result. There is no window between fork and reset in which Launch Manager’s handlers run in the child |
uid / gid ( |
Child: |
|
Same result. A failure makes |
Supplementary groups ( |
Child: |
Launch Manager: |
Same result. Applied by Launch Manager to another process instead of by the child to itself |
Scheduling policy / priority ( |
Child: |
Launch Manager: |
Same priority: it is now clamped to |
CPU affinity ( |
Child: |
|
Set at process creation instead of before exec. Threads created later should inherit the mask, as they do with the explicit inherit mask on the fork path (to be confirmed) |
Resource limits ( |
Child: |
Launch Manager: |
Same limits, but set by Launch Manager on another process instead of by the child on itself |
RLIMIT_STACK (in |
|
Also |
If the soft limit is |
Working directory ( |
Child: |
Launch Manager opens the directory ( |
A directory the target uid cannot access was rejected before and is now accepted. However, the child fails to access any files if its credentials do not allow it. |
Security policy ( |
Child: |
|
The process runs in its security type from the start, with no transition by the child. Launch Manager’s policy must allow spawning into the type instead of the child’s transition |
Error handling and observable behavior#
Aspect |
fork() + execve() (current) |
posix_spawn() (QNX, new) |
|---|---|---|
Failure while preparing (attributes, |
Child exits with |
|
Failure while configuring the held process (scheduling, groups, rlimits) |
n/a (all done in the child) |
|
Termination status seen by Launch Manager after a setup failure |
|
|
Multiple failing settings |
|
Stops at the first failure |
Logging |
|
Regular |
|
n/a |
Error logged and |
|
Needed so buffered output is not duplicated |
Not needed |
Order of application |
signals → comms fd → rlimits → pgid → scheduling → affinity → gid → groups → uid → chdir → secpol → exec |
At spawn: pgid, signals, affinity, uid/gid, stack max, cwd, security type, comms fd. While held: scheduling → groups → rlimits. Then |