title: Terminal text becomes invisible after terminating subprocess
body: <p>After terminating an <code>ffmpeg</code> subprocess, the terminal gets messed up - typed characters are invisible!  The input still works in that commands can be executed, but keyboard input is not echoed to the terminal.  </p>
  
  <p>Issuing shell command <code>reset</code> puts everything back to normal (or <code>!reset</code> from within ipython), so a workaround the issue is calling <code>os.system('reset')</code> inside the script.  </p>
  
  <p>Other things I've tried:  <code>import curses; curses.initscr()</code> before spawning the subprocess and <code>curses.endwin()</code> after termination, which worked somewhat but broke other stuff.  Another possibly related issue is that after spawning the child process, the interactive terminal becomes laggy and sometimes fails to capture typed characters.  </p>
  
  <p>The code to spawn the process looks like:</p>
  
  <pre><code>with open('/tmp/stdout.log', 'w') as o:
      with open('/tmp/stderr.log', 'w') as e:
          proc = subprocess.Popen([args], stdout=o, stderr=e)
  </code></pre>
  
  <p>And later to stop it:</p>
  
  <pre><code>proc.terminate()
  proc.communicate()
  </code></pre>
  
  <p>What could be going wrong here?</p>