python - 使用 CPU 的已失效进程

标签 python linux unix ps

ps aux 的输出包含以下内容:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
ubuntu    1496  9.1  0.0      0     0 pts/0    Z+   19:47   0:30 [python] <defunct>
ubuntu    1501 14.6  0.0      0     0 pts/0    Z+   19:47   0:48 [python] <defunct>
ubuntu    1502 14.8  0.0      0     0 pts/0    Z+   19:47   0:48 [python] <defunct>
ubuntu    1503 15.1  0.0      0     0 pts/0    Z+   19:47   0:49 [python] <defunct>
ubuntu    1504 15.4  0.0      0     0 pts/0    Z+   19:47   0:50 [python] <defunct>
ubuntu    1505 15.8  0.0      0     0 pts/0    Z+   19:47   0:52 [python] <defunct>
ubuntu    1506 16.0  0.0      0     0 pts/0    Z+   19:47   0:53 [python] <defunct>
ubuntu    1507 14.1  0.0      0     0 pts/0    Z+   19:47   0:46 [python] <defunct>
ubuntu    1508 14.3  0.0      0     0 pts/0    Z+   19:47   0:47 [python] <defunct>
ubuntu    1509 14.4  0.0      0     0 pts/0    Z+   19:47   0:47 [python] <defunct>
ubuntu    1510 14.6  0.0      0     0 pts/0    Z+   19:47   0:48 [python] <defunct>
ubuntu    1511 14.9  0.0      0     0 pts/0    Z+   19:47   0:49 [python] <defunct>
ubuntu    1512 10.7  0.0      0     0 pts/0    Z+   19:47   0:35 [python] <defunct>
ubuntu    1513 71.3  0.0      0     0 pts/0    Z+   19:47   3:55 [python] <defunct>

这些是通过多处理产生的一堆进程,它们已经完成并等待父进程加入。他们为什么占用CPU?

如果这只是 ps 的产物,我如何才能准确了解正在使用的 CPU 量?

最佳答案

僵尸进程(即“已停用”的进程)不消耗 CPU:它只是由内核保留,以便父进程可以检索有关它的信息(例如返回状态、资源使用情况等...) .

ps 命令指示的 CPU 使用率对应于进程运行时的 CPU 使用率:也就是说,它终止并成为僵尸之前。

关于python - 使用 CPU 的已失效进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22234609/

相关文章:

Python:如何使 __Init__ 调用两种不同的参数方法?

python - Pandas:导入带有多个工作表的 xlsx,将列添加到每个 df 及其所属工作表的名称,连接具有相同列数的 df

linux - 如何 ssh+expect 登录并 su 到远程机器上的另一个用户?

batch-file - 在 Windows 批处理文件中使用 sed 或 tr 命令将双引号替换为空格

为多个作者在管道中交错的 block ?

c - 从串行端口读取时如何实现 read() 超时 (C/C++)

python - 带有类型推导的 swig python 模板函数

python - 在Python中使用<128KB的字符串时发生内存泄漏?

linux - 如何清除父进程设置的子进程中的陷阱?

linux - 在 Linux 中打印 CSV 文件中的一列