Inheritance

A program or process image file loaded using spawn() inherits certain characteristics of the parent process. Because spawn() is effectively a functional combination of fork() and exec(), the inherited attributes are an accumulation of the attributes of the two functions. Table 1 illustrates this relationship. By following across the table from left to right, you will find in nearly every case that each characteristic of spawn() is shown by either fork() or exec() or both.
Table 1. Comparison of spawn() Attributes to fork() and exec()
Attribute fork() exec() spawn()
Process PID Changed Not Changed Changed
Process Group ID Not Changed Not Changed Not Changed 1
Parent PID Changed Not Changed Changed
Session Membership Not Changed Not Changed Not Changed
Real UID Not Changed Not Changed Not Changed
Real GID Not Changed Not Changed Not Changed
Effective UID Not Changed May Change 2 May Change 2
Effective GID Not Changed May Change 2 May Change 2
Saved-Set UID Not Changed May Change 3 May Change 3
Saved-Set GID Not Changed May Change 3 May Change 3
Supplemental GIDs Not Changed Not Changed Not Changed
Time Left on Alarms Reset to 0 Not Changed Reset to 0
Process Signal Mask Not Changed Not Changed Not Changed 4
Pending Signals Empty Set Not Changed Empty Set
Signals Set to Be Caught Not Changed Caught set to SIG_DFL Caught set to SIG_DFL
Signals Set to Default Action Not Changed Not Changed Not Changed
Signals Set to Ignore Not Changed Not Changed Not Changed 5
Process Times Cleared to 0 Not Changed Cleared to 0
Open File Descriptors Closed if FD_CLOFORK set 6 Closed if FD_CLOEXEC set 6 Closed if FD_CLOEXEC, FD_CLOFORK, or SPAWN_FDCLOSED 6
Open Directory Streams Duplicated Closed Closed
File Locks Not Inherited Not Changed if file still open Not Inherited
Current Working Directory Not Changed Not Changed Not Changed
Root Directory Not Changed Not Changed Not Changed
File Creation Mask Not Changed Not Changed Not Changed
Memory Locks Not Changed Released Released
Note:
  1. The process group ID may be changed with the inherit parameter. See Inheritance Structure.
  2. When a new process is created by spawn(), if the set-user-ID mode bit is set in the new process image, the effective user ID is set to the owner of the new process image file. If the set-group-ID mode bit is set, the effective group ID of the new process image file is set to the group of the new process image file.
  3. The effective user ID and effective group ID of the new process are saved as the saved-set UID and saved-set GID.
  4. The signal mask can be changed using the inherit parameter. See Inheritance Structure.
  5. The signals forced to the default action in the child process can be controlled with the inherit parameter. See Inheritance Structure.
  6. FD_CLOEXEC and FD_CLOFORK can be set by fcntl() on an open file. If this flag is set, the flagged file is closed in the new process after the spawn(). SPAWN_FDCLOSED is a value set in the map[] array of spawn(). If an array element has this value, that file descriptor is closed in the new process. Every element of the map[] array must have a valid value. If the array element does not have a mapped array element, it must contain the constant SPAWN_FDCLOSED.