title: Shell hangs after killing subprocess
body: <p>I know there are a bunch of similar questions on SO like <a href="https://stackoverflow.com/questions/1624254/how-do-i-close-the-stdout-pipe-when-killing-a-process-started-with-python-subpro">this one</a> or <a href="https://stackoverflow.com/questions/2151640/pythons-subprocess-popen-object-hangs-gathering-child-output-when-child-process">this one</a> and maybe a couple more, but none of them seem to apply in my particular situation. My lack of understanding on how <code>subprocess.Popen()</code> works doesn't help either.</p>
  
  <p>What i want to achieve is:  launch a subprocess (a command line radio player) that also outputs data to the terminal and can also receive input -- wait for a while -- terminate the subprocess -- exit the shell. I am running python 2.7 on OSX 10.9</p>
  
  <p><strong>Case 1.</strong>
  This launches the radio player (but audio only!), terminates the process, exits.</p>
  
  <pre><code>import subprocess
  import time
  
  p = subprocess.Popen(['/bin/bash', '-c', 'mplayer http://173.239.76.147:8090'],
                       stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=False,
                       stderr=subprocess.STDOUT)
  time.sleep(5)
  p.kill()
  </code></pre>
  
  <p><strong>Case 2.</strong>
  This launches the radio player, outputs information like radio name, song, bitrate, etc and also accepts input. It terminates the subprocess but it never exists the shell and the terminal becomes unusable even after using 'Ctrl-C'.</p>
  
  <pre><code>p = subprocess.Popen(['/bin/bash', '-c', 'mplayer http://173.239.76.147:8090'],
                       shell=False)
  time.sleep(5)
  p.kill()
  </code></pre>
  
  <p>Any ideas on how to do it? I was even thinking at the possibility of opening a <em>slave-shell</em> for the subprocess if there is no other choice (of course it is also something that I don't have a clue about). Thanks!</p>