linuxparallel-processingwgetgnu-parallelsigchld

How To Avoid SIGCHLD error In Bash Script That Uses GNU Parallel


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.

The loop looks like this:

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

Research:

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.

Trying To Understand:

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?

My question:

How can I solve the SIGCHLD error?

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


Solution

  • 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.