title: How to terminate a python subprocess launched with shell=True
body: <p>I'm launching a subprocess with the following command:</p>
  
  <pre><code>p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
  </code></pre>
  
  <p>However, when I try to kill using:</p>
  
  <pre><code>p.terminate()
  </code></pre>
  
  <p>or </p>
  
  <pre><code>p.kill()
  </code></pre>
  
  <p>The command keeps running in the background, so I was wondering how can I actually terminate the process. </p>
  
  <p>Note that when I run the command with:</p>
  
  <pre><code>p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
  </code></pre>
  
  <p>It does terminate successfully when issuing the <code>p.terminate()</code>.</p>