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

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.

主站蜘蛛池模板: 靖西县| 平遥县| 舒城县| 太白县| 久治县| 汉阴县| 大洼县| 穆棱市| 绥芬河市| 齐河县| 威海市| 应城市| 云和县| 龙泉市| 尼木县| 蕉岭县| 防城港市| 新丰县| 康平县| 成安县| 平乐县| 龙海市| 大荔县| 黑河市| 五华县| 万源市| 大英县| 河津市| 乌拉特后旗| 英超| 年辖:市辖区| 吐鲁番市| 烟台市| 保靖县| 黔西县| 喜德县| 武胜县| 秭归县| 许昌市| 绍兴市| 黑河市|