孩子是家长的 副本。例如,孩子获取父母的数据空间,堆和堆栈的副本。请注意,这个 是儿童的副本;父母和孩子不共享这些内存部分
fork的一个特点是在父项中打开的所有文件描述符都是 在子项中复制。
但是也有一些由子继承父的许多其他性质:
1. real user ID, real group ID, effective user ID, effective group ID
2. supplementary group IDs
3. process group ID
4. session ID
5. controlling terminal
6. set-user-ID flag and set-group-ID flag
7. current working directory
8. root directory
9. file mode creation mask
10. signal mask and dispositions
11. the close-on-exec flag for any open file descriptors
12. environment
13. attached shared memory segments
14. resource limits
15. Memory mappings
的父母和孩子之间的差异是
1. the return value from fork
2. the process IDs are different
3. the two processes have different parent process IDs—the parent process ID of the child is the parent; the parent process ID of the parent doesn't change
4. the child's values for tms_utime, tms_stime, tms_cutime, and tms_ustime are set to 0
5. file locks set by the parent are not inherited by the child
6. pending alarms are cleared for the child
7. the set of pending signals for the child is set to the empty set