title: closing stdout of piped python subprocess
body: <p>Here is what I can read in the python subprocess module documentation:</p>
  
  <pre><code>Replacing shell pipeline
  
      output=`dmesg | grep hda`
      ==&gt;
      p1 = Popen(["dmesg"], stdout=PIPE)
      p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
      p1.stdout.close()  # Allow p1 to receive a SIGPIPE if p2 exits.
      output = p2.communicate()[0]
  
  The p1.stdout.close() call after starting the p2 is important in order for p1
  to receive a SIGPIPE if p2 exits before p1.
  </code></pre>
  
  <p>I don't really understand why we have to close p1.stdout after have created p2.
  When is exactly executed the p1.stdout.close()?
  What happens when p2 never ends?
  What happens when nor p1 or p2 end?</p>