官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 营口市| 平罗县| 泗洪县| 通化县| 板桥市| 雅安市| 德化县| 呈贡县| 格尔木市| 桐城市| 凌云县| 陇西县| 东海县| 冷水江市| 清原| 昌平区| 潜山县| 霍邱县| 东莞市| 延川县| SHOW| 区。| 广州市| 绥德县| 崇左市| 济源市| 临清市| 抚宁县| 台东市| 普安县| 阆中市| 瓮安县| 陈巴尔虎旗| 博白县| 陈巴尔虎旗| 石林| 昭平县| 屏边| 兴安盟| 双牌县| 普兰县|