title: How do I terminate all the subshell processes?
body: <p>I have a bash script to test how a server performs under load.</p>
  
  <pre><code>num=1
  if [ $# -gt 0 ]; then
      num=$1
  fi
  for i in {1 .. $num}; do
      (while true; do
          { time curl --silent 'http://localhost'; } 2&gt;&amp;1 | grep real
      done) &amp;
  done        
  
  wait
  </code></pre>
  
  <p>When I hit Ctrl-C, the main process exits, but the background loops keep running. How do I make them all exit? Or is there a better way of spawning a configurable number of logic loops executing in parallel?</p>