title: Bash wait for async job in non-interactive shell without tty / job control
body: <p>I'm trying to run a number of jobs in parallel using a bash script run in a non-interactive shell.</p>
  
  <p>I do not want the main script to terminate until all child processes have terminated as well.</p>
  
  <p>Here's an example of what I'm trying to do:</p>
  
  <pre><code>while (( "$#" )); do
    some_long_task "$1" &amp;
  done
  
  for job in `jobs -p`; do
    wait $job || echo 'Could not wait for job: ' $job
  done
  </code></pre>
  
  <p>which gives me <code>bash:no job control in this shell</code> as an error and terminates before finishing the jobs.</p>
  
  <p>How can I have bash wait for each of the child processes?</p>