- Mastering Linux Kernel Development
- Raghu Bharadwaj
- 202字
- 2021-07-08 09:47:20
exit
Every process must end. Process termination is done either by the process calling exit() or when the main function returns. A process may also be terminated abruptly on receiving a signal or exception that forces it to terminate, such as the KILL command, which sends a signal to kill the process, or when an exception is raised. Upon termination, the process is put into exit state until the immediate parent reaps it.
The exit calls the sys_exit system call, which internally calls the do_exit routine. The do_exit primarily performs the following tasks (do_exit sets many values and makes multiple calls to related kernel routines to complete its task):
- Takes the exit code returned by the child to the parent.
- Sets the PF_EXITING flag, indicating process exiting.
- Cleans up and reclaims the resources held by the process. This includes releasing mm_struct, removal from the queue if it is waiting for an IPC semaphore, release of filesystem data and files, if any, and calling schedule() as the process is no longer executable.
After do_exit, the process remains in zombie state and the process descriptor is still intact for the parent to collect the status, after which the resources are reclaimed by the system.
- Java EE 6 企業級應用開發教程
- ASP.NET MVC4框架揭秘
- 少年輕松趣編程:用Scratch創作自己的小游戲
- 精通Scrapy網絡爬蟲
- Unreal Engine 4 Shaders and Effects Cookbook
- RISC-V體系結構編程與實踐(第2版)
- Learning Probabilistic Graphical Models in R
- 圖數據庫實戰
- 響應式Web設計:HTML5和CSS3實戰(第2版)
- 從零開始學Android開發
- Mastering Gephi Network Visualization
- 軟件測試技術
- React.js實戰
- 程序員超強大腦
- Go語言從入門到進階實戰(視頻教學版)