title: How to kill all asynchronous processes
body: <p>Suppose we have a BASH script running some commands in the background. At some time we want to kill all of them, whether they have finished their job or not.</p>
  
  <p>Here's an example:</p>
  
  <pre><code>function command_doing_nothing () {
    sleep 10
    echo "I'm done"
  }
  
  for (( i = 0; i &lt; 3; i++ )); do
    command_doing_nothing &amp;
  done
  
  echo "Jobs:"
  jobs
  
  sleep 1
  
  # Now we want to kill them
  </code></pre>
  
  <p>How to kill those 3 jobs running in the background?</p>