如何避免在使用GNU Parallel的Bash脚本中出现SIGCHLD错误 [英] How To Avoid SIGCHLD error In Bash Script That Uses GNU Parallel

查看:129
本文介绍了如何避免在使用GNU Parallel的Bash脚本中出现SIGCHLD错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在循环运行script.sh.该脚本包含一个并行的wget命令.我收到以下错误:

I'm running a script.sh in a loop. The script contains a parallel wget command. I'm getting the following error:

Signal SIGCHLD received, but no signal handler set.

循环看起来像这样:

for i in {1..5}; do /script.sh; done

导致错误的行如下所示(省略选项和设置):

And the line that is causing the error looks like this (omitting options and settings):

cat file.txt | parallel -j15 wget

研究:

我不是GNU Parallel的专家,但是该脚本在大多数情况下都可以正常运行,除非出现上述错误.在查找SIGCHLD时,我了解到并行运行可以创建僵尸进程",有时,我们需要收获"这些进程.另外,我发现您可以杀死进程,因为有时它们会占用所有可用的连接.

I'm not an expert with GNU Parallel, but the script seems to work fine most of the time except when I get the error above. While looking up SIGCHLD, I learned that running parallel can create "zombie processes" and sometimes, we need to "reap" these processes. Also, I found that you can kill processes because sometimes they can take up all the available connections.

试图理解:

但是,首先我不知道是什么引起了该问题.是我的相似之处吗?我不是在收获"过程吗?我应该明确地终止进程吗?是因为我在循环中运行并行脚本吗?

However, I don't know what is causing the issue in the first place. Is it my parallels? Am I not "reaping" processes? Should I be killing processes explicitly? Is it because I am running a parallel script in a loop?

我的问题:

如何解决SIGCHLD错误?

How can I solve the SIGCHLD error?

如果您对此有任何经验,将非常感谢您的见解.

If you have any experience with this, your insight is greatly appreciated.

推荐答案

我认为这可能是并行的错误.在代码中有一点是作者正在删除sigchld处理程序,大概是作为忽略信号的一种方式. Perl文档对可能产生的影响保持沉默,向我暗示结果将取决于平台或实现且不可靠.忽略信号的正确方法是将处理程序设置为"INGORE".我建议尝试使用版本20150222,该版本确实包含此可疑代码.

I think this might be a bug in parallel. There is a point in the code where the author is deleting the sigchld handler, presumably as a way of ignoring the signal. The perl documentation is silent on the effect that would have, suggesting to me that the result will be platform or implementation dependent and unreliable. The proper way to ignore a signal is to set the handler to "INGORE". I suggest trying version 20150222, an older version which does have this questionable code.

这篇关于如何避免在使用GNU Parallel的Bash脚本中出现SIGCHLD错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆