Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 1
    You can also use SIGCHLD trap to process the children when they exit, such as printing out the status at that time. Or updating a progress counter: declare a function then use "trap function_name CHLD" though that may also require an option to be turned on in a non-interactive shell, such as possibly "set -m" Commented Feb 12, 2017 at 13:42
  • 1
    Also "wait -n" will wait for any child and then return the exit status of that child in the $? variable. So you can print progress as each one exits. However note that unless you use the CHLD trap, you may miss some child exits that way. Commented Feb 12, 2017 at 13:52
  • @Chunko thanks! that is good info, could you maybe update the answer with something you think is best? Commented Feb 12, 2017 at 20:04
  • thanks @Chunko, trap works better, you're right. With wait <pid>, I got fallthrough. Commented Feb 13, 2017 at 9:37
  • Can you explain how and why you believe the version with the trap is better than the one without it?  (I believe that it’s no better, and therefore that it is worse, because it is more complex with no benefit.) Commented Mar 29, 2018 at 6:54