使用并行包删除僵尸进程 [英] Remove zombie processes using parallel package
问题描述
在我基于 Debian 的机器上使用 R 的并行包玩了一段时间后,我仍然找不到在计算后删除所有僵尸子进程的方法.
After I have played around for some time using R's parallel package on my Debian-based machine I still can't find a way to remove all zombie child-processes after a computation.
我正在寻找通用且独立于操作系统的解决方案.
I'm searching for a general and OS independent solution.
下面是说明 2 个内核问题的简单脚本:
Below a simple script illustrating the problem for 2 cores:
library(parallel)
testfun <- function(){TRUE}
cltype <- ifelse(.Platform$OS.type != "windows", "FORK", "PSOCK")
cl <- makeCluster(2, type = cltype)
p <- clusterCall(cl, testfun)
stopCluster(cl)
不幸的是,这个脚本在进程表中留下了两个僵尸进程,只有在 R 关闭时它们才会被杀死.
Unfortunately, this script leaves two zombie processes in the process table which only get killed if R is shut down.
推荐答案
这似乎只是FORK"集群的问题.如果您改为创建PSOCK"集群,则当您调用 stopCluster(cl)
时,进程将终止.
This only seems to be an issue with "FORK" clusters. If you make a "PSOCK" cluster instead, the processes will die when you call stopCluster(cl)
.
是否有任何因素阻止您在基于 Debian 的机器上使用PSOCK"集群?
Is there anything preventing you from using a "PSOCK" cluster on your Debian-based machine?
这篇关于使用并行包删除僵尸进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!