title: jmx-term python subprocess poisons shell
body: <pre><code>#!/usr/bin/env python
  
  from subprocess import *
  
  p = Popen(
    args=("java","-jar","jmxterm-1.0-alpha-4-uber.jar"), 
    bufsize=0, 
    stdin=PIPE,
    stderr=PIPE
    )
  
  p.stdin.write("open localhost:12345\n")
  x = p.stderr.readline()
  </code></pre>
  
  <p>This needs a java process listening for a jmx client on port 12345.
  The script "works": x is correct (when you print it or look at it in pdb).  </p>
  
  <p><strong>What's the problem then?</strong> When this script terminates, the shell behaves strangely. On Linux and OS-X, typing in the shell isn't visible (although output is), and on windows, the first two characters typed per command are ignored. Executing the terminal "reset" command seems to fix it, but I don't want to inflict this on users of my script.</p>
  
  <p>Removing the last line of the script (accessing p.stderr.readline()) eliminates the problem, but also the script's utility.</p>
  
  <p>I've removed authentication to simplify the example. You'll note that I don't print x, to eliminate writing something nasty to the the shell as a culprit.</p>
  
  <p>Versions: CPython 2.7 on Snow Leopard and various Linuxes; CPython 2.6.3 on Windows 7</p>