title: When java program is started using Python's subprocess.Popen() exits, why database connection opened by the subprocess is not closed?
body: <p>We use Robot Framework for test automation, and our jython test code spawns a java subprocess using subprocess.Popen():</p>
  
  <pre><code>    cmd = "java -jar program.jar"
      process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
      process.wait()
  </code></pre>
  
  <p>Java code utilizes a JDBC connection to Oracle database, and the same program needs to be executed several times successively.</p>
  
  <p>Our issue is, that after the java program exits the database connection to Oracle is not closed - and after several executions the tests start to fail because Oracle won't accept more connections.</p>
  
  <p>netstat shows, that the stale TCP connections to Oracle are owned by jython's PID (=parent process).</p>
  
  <p>Why aren't the connections closed when the java program (=subprocess) exits?</p>