title: how to kill a process group using Python subprocess
body: <p>I am trying to do the equivalent of the following using Python subprocess:</p>
  
  <pre><code>&gt;cat /var/log/dmesg | festival --tts &amp;
  [1] 30875
  &gt;kill -9 -30875
  </code></pre>
  
  <p>Note that I am killing the process <em>group</em> (as indicated by the negative sign prepending the process ID number) in order to kill all of the child processes Festival launches.</p>
  
  <p>In Python, I currently have the following code, wherein two processes are created and linked via a pipe.</p>
  
  <pre><code>process_cat = subprocess.Popen([
      "cat",
      "/var/log/dmesg"
  ], stdout = subprocess.PIPE)
  process_Festival = subprocess.Popen([
      "festival",
      "--tts"
  ], stdin = process_cat.stdout, stdout = subprocess.PIPE)
  </code></pre>
  
  <p>How should I kill these processes and their child processes in a way equivalent to the Bash way shown above? The following approach is insufficient because it does not kill the child processes:</p>
  
  <pre><code>os.kill(process_cat.pid, signal.SIGKILL)
  os.kill(process_Festival.pid, signal.SIGKILL)
  </code></pre>
  
  <p>Is there a more elegant way to do this, perhaps using just one process?</p>