title: Killing child process when parent crashes in python
body: <p>I am trying to write a python program to test a server written in C. The python program launches the compiled server using the <code>subprocess</code> module:</p>
  
  <pre><code>pid = subprocess.Popen(args.server_file_path).pid
  </code></pre>
  
  <p>This works fine, however if the python program terminates unexpectedly due to an error, the spawned process is left running. I need a way to ensure that if the python program exits unexpectedly, the server process is killed as well. </p>
  
  <p>Some more details:</p>
  
  <ul>
  <li>Linux or OSX operating systems only</li>
  <li>Server code can not be modified in any way</li>
  </ul>