title: Bash & (ampersand) operator
body: <p>I'm trying to run 3 commands in parallel in bash shell:</p>
  
  <pre><code>$ (first command) &amp; (second command) &amp; (third command) &amp; wait
  </code></pre>
  
  <p>The problem with this is that if <code>first command</code> fails, for example, the exit code is <code>0</code> (I guess because <code>wait</code> succeeds).</p>
  
  <p>The desired behavior is that if one of the commands fails, the exit code will be non-zero (and ideally, the other running commands will be stopped).</p>
  
  <p>How could I achieve this?</p>
  
  <p>Please note that I want to run the commands in parallel!</p>