免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2006 | 回复: 8
打印 上一主题 下一主题

如果父进程没有对僵尸子进程进行wait操作,僵尸进程在内核空间留下的信息谁来清除 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-31 12:21 |只看该作者 |倒序浏览
The kernel keeps a small amount of information for every terminating process, so that the information is available when the parent of the terminating process calls wait or waitpid. Minimally, this information consists of the process ID, the termination status of the process, and the amount of CPU time taken by the process. The kernel can discard all the memory used by the process and close its open files.

如果父进程对僵尸进程进行wait,这些信息的清除(红色部分标识)是在执行wait过程中吗

如果没有进行wait,是父进程返回内核以后由内核代码清除的吗

论坛徽章:
0
2 [报告]
发表于 2008-12-31 12:25 |只看该作者
init进程变成它们的父进程,所以是由它来清除的

论坛徽章:
0
3 [报告]
发表于 2008-12-31 12:32 |只看该作者
还准备问应该不会被init进程收养让init来清除呢
没想到楼上这么快就否定了我的想法 :)

在apue有这么一段话
What normally happens is that whenever a process terminates, the kernel goes through all active processes to see whether the terminating process is the parent of any process that still exists. If so, the parent process ID of the surviving process is changed to be 1 (the process ID of init). This way, we're guaranteed that every process has a parent.

难道成为僵尸的子进程也属于any process that still exists?

论坛徽章:
0
4 [报告]
发表于 2008-12-31 13:20 |只看该作者
父进程退出后,子进程有init收养

论坛徽章:
0
5 [报告]
发表于 2009-01-03 10:15 |只看该作者
原帖由 cugb_cat 于 2008-12-31 13:20 发表
父进程退出后,子进程有init收养


正解

论坛徽章:
0
6 [报告]
发表于 2009-01-03 14:03 |只看该作者
如果首先子进程成为了僵尸进程,然后父进程退出,僵尸子进程也由init收养?

论坛徽章:
0
7 [报告]
发表于 2009-01-03 20:32 |只看该作者

回复 #6 zhuhefang2006 的帖子

在进程的父子关系上面是init进程收养。

论坛徽章:
0
8 [报告]
发表于 2009-01-03 21:04 |只看该作者
原帖由 zhuhefang2006 于 2009-1-3 14:03 发表
如果首先子进程成为了僵尸进程,然后父进程退出,僵尸子进程也由init收养?

论坛徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11数据库技术版块每日发帖之星
日期:2016-08-03 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
9 [报告]
发表于 2009-01-03 21:14 |只看该作者
那么僵尸将与父进程"共生死",父进程不挂,僵尸就不挂;父进程挂了,init收养僵尸并给它收尸
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP