Timeline for Collect exit codes of parallel background processes (sub shells)
Current License: CC BY-SA 3.0
18 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 8, 2022 at 10:40 | comment | added | pmor | Consider subshells X and Y, each executed in parallel. Consider that we need to implement "if any subshell failed, then all subshells failed" logic. If waiting of X and Y is done sequentially (as in your answer) AND if, for example, Y failed while waiting of X, then there is no need to wait X. How to implement, more precisely, "if any subshell failed, then kill immediately all other subshells"? | |
| Nov 5, 2022 at 2:28 | comment | added | Michael Homer | @pmor wait on the PID of Y in the same way. | |
| Nov 1, 2022 at 17:27 | comment | added | pmor |
So how do you know what job Y returned?
|
|
| Apr 11, 2018 at 12:39 | comment | added | Alexander Mills | Yeah @arberg used your idea and solved it your way, I changed the accepted answer to argberg's. if you think his answer needs to work please comment on that answer below thanks. | |
| Feb 12, 2017 at 9:46 | review | Suggested edits | |||
| Feb 12, 2017 at 11:08 | |||||
| Feb 12, 2017 at 9:43 | comment | added | Alexander Mills | LOL, ok I see, but it's not super clear, let me update your answer, thanks :) | |
| Feb 12, 2017 at 9:42 | comment | added | Michael Homer |
You'll never guess what happens when you run wait $Y.
|
|
| Feb 12, 2017 at 9:42 | comment | added | Alexander Mills | I guess like you said I can loop over the results and than call wait on each one. (right?) | |
| Feb 12, 2017 at 9:41 | comment | added | Alexander Mills | oh, I need the exit codes of all the sub processes, not just the first one | |
| Feb 12, 2017 at 9:38 | comment | added | Michael Homer | Because you wanted to collect the exit code of that process. | |
| Feb 12, 2017 at 9:36 | comment | added | Alexander Mills | I mean $X represents the PID of the first process, but why would you want to use that with wait? | |
| Feb 12, 2017 at 9:33 | comment | added | Michael Homer |
You run wait $X at any (reasonable) later point.
|
|
| Feb 12, 2017 at 9:31 | history | edited | Michael Homer | CC BY-SA 3.0 |
added 101 characters in body
|
| Feb 12, 2017 at 9:31 | comment | added | Alexander Mills | yes thanks I will check that out, if the wait command pertains to your answer, then please add it | |
| Feb 12, 2017 at 9:30 | comment | added | Michael Homer | @AlexanderMills They are running in parallel. If you have a variable number of them, use an array. (as e.g. here which may thus be a duplicate). | |
| Feb 12, 2017 at 9:30 | comment | added | Alexander Mills | nevermind, maybe this works with my setup...where does the wait command come into play in your code? I don't follow | |
| Feb 12, 2017 at 9:28 | comment | added | Alexander Mills | ughh, sorry, I need to run these subshells in parallel, I will specify that in the question... | |
| Feb 12, 2017 at 9:25 | history | answered | Michael Homer | CC BY-SA 3.0 |