title: os.kill in for loop throws exception
body: <p>I have a for loop which opens a application with <code>subprocess.Popen</code> and closes it with <code>os.kill</code>. </p>
  
  <p>Whole code:</p>
  
  <pre><code>import subprocess
  import time
  import signal
  import os
  
  with open('programs.txt') as f:
      programs = f.readlines()
  
  programs = [x.strip() for x in programs] 
  
  for program in programs: 
      programOpened = subprocess.Popen([r"C:\\path\\to\\application\\" + program])
      time.sleep(5)
  
      os.kill(programOpened.pid, signal.CTRL_C_EVENT)
  </code></pre>
  
  <p>This throws for my this exception:</p>
  
  <pre><code>os.kill(programOpened.pid, signal.CTRL_C_EVENT) 
  SystemError: &lt;built-in function kill&gt; returned a result with an error set
  </code></pre>
  
  <p>Why is this exception thrown and how could i close a subprocess in a for loop?</p>