title: How to fail the whole the primary process if one of the background processes fails in bash?
body: <p>So basically I need to</p>
  <ul>
  <li>run <code>stubs</code>, <code>server</code> and <code>wait</code> simultaneously</li>
  <li>when <code>wait</code> completes, run <code>tests</code></li>
  <li>if <code>stubs</code> or <code>server</code> fail, the main process with <code>wait</code> and <code>tests</code> should fail too (because otherwise it stays hanging in there till 1 hour timeout)</li>
  </ul>
  <p>The rest of the gibberish is my original question:
  I'm running e2e tests in gitlab ci. the simplified script is this:</p>
  <pre><code>stubs &amp; server &amp; wait-on &amp;&amp; test
  </code></pre>
  <p>wait-on is checking when the server starts responding on a specific url and after that the tests start running. The question is how do I fail the whole ci job if <code>stubs</code> or <code>server</code> fails?</p>
  <p>In a sunny day scenario they run in background till the tests finish running and the container gets killed, but how do I kill the container in a rainy day scenario when at least one of them can't compile?</p>
  <p>Update: It seems I didn't make myself clear, I am sorry. so there are 2 scenarios:</p>
  <ol>
  <li><p>sunny: stubs and server are compiled and are run in background forever (till the container gets killed after <code>test</code> is completed) - this works as expected</p>
  </li>
  <li><p>rainy: <code>stubs</code> or <code>server</code> couldn't compile. in this case wait-on will wait forever till the container is killed by timeout  (1 hour in my case) - this is what I want to improve: I don't want to wait for an hour, but finish everything with an error as soon as <code>stubs</code> or <code>server</code> had failed</p>
  </li>
  </ol>
  <p>Thanks for helping, I'm really bad with bash, sorry</p>