title: Getting stdout from a tcpdump subprocess after terminating it
body: <p>I am running <code>tcpdump</code> in a subprocess like this:</p>
  
  <pre><code>pcap_process = subprocess.Popen(['tcpdump', '-s 0', '-w -', 'tcp'], 
                                    stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  </code></pre>
  
  <p>The <code>-w -</code> argument is important: it tells <code>tcpdump</code> to print the resulting .pcap file to <code>stdout</code>.</p>
  
  <p>I then go on to access a website using <code>urllib.open()</code>. After this is done, I would like to kill <code>tcpdump</code> and put whatever it printed into a string. I have tried the following:</p>
  
  <pre><code>pcap_process.terminate()
  result = pcap_process.stdout.read()    # or readline(), etc.
  </code></pre>
  
  <p>But (unless I'm doing something wrong), that doesn't work; I killed the process, now there's nothing left to be read. If I use <code>read()</code> or <code>communicate()</code> before terminating, my script will just sit there and read on and on, waiting for <code>tcpdump</code> to finish (which it won't).</p>
  
  <p>Is there a way to do this (preferably without loops)?</p>