Process Creation & Termination
flowchart LR fork["fork()"] wait["wait"] resumes["resumes"] exec["exec()"] exit["exit()"] fork -->|parent| wait wait --> resumes fork -->|child| exec exec --> exit exit -.-> wait style exit stroke:#ff9999,stroke-width:3px
很重要的一張圖
fork
Termination
Normal Termination
- Return from main()
- D-SP-Ch8bc-exit
Abnormal Termination
- call
abort()(這就是跟 kernel 説:「我要自殺了」,然後 kernel 説:「我準了」) - terminated by signal
wait
- D-SP-Ch8bd-wait_waitpid_waitid
- D-SP-Ch8be-wait3_wait4
- D-SP-Ch8bf-zombie_orphan
- D-SP-Ch8bg-race_condition