c - 为什么长时间运行的程序总是要收割它们的僵尸 child ?

标签 c linux fork child-process zombie-process

我正在阅读一本关于父/子过程的教科书,作者说:

If a parent process terminates without reaping its zombie children, then the kernel arranges for the init process to reap them. However, long-running programs such as shells or servers should always reap their zombie children. Even though zombies are not running, they still consume system memory resources.

但是根据这个问题的回答What does reaping children imply?
似乎大部分/所有僵尸的资源都被释放了,只有一个资源肯定还在消耗是那个进程表槽。 process table slot我不熟悉,但我认为它存储了僵尸的退出状态。

无论如何,进程表槽中的一条记录听起来没什么大不了的,可能只消耗几个字节/kb 的内存,所以为什么长时间运行的程序应该总是通过调用 等等变体?

最佳答案

进程数有上限,最低可达32768。

出于此目的,僵尸进程仍算作进程。

如果您创建了数千个僵尸进程并且不回收它们,系统将无法创建更多进程。这很糟糕。

关于c - 为什么长时间运行的程序总是要收割它们的僵尸 child ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63792927/

相关文章:

c - 将字符数组作为参数传递(C 内核代码)

c - 迭代 "opaque"抽象数据类型的最佳方式

c - 在 Linux 上用 C 语言从 PID 打印文件描述符

linux - 使用 iptables 规则记录 https 上的所有流量

Python:进程被杀死后多次打印到控制台

c - fork - 子进程数量

c - eiffel c编译失败: error LNK2001: unresolved external symbol

c - c函数中WINAPI标签的专有名称是什么?

linux - valid_referers nginx http 和 https

apache - Fork shell 脚本(不是 &)