title: Should I always close stdout explicitly?
body: <p>I am trying to integrate a small Win32 C++ program which reads from stdin and writes the decoded result (˜128 kbytes)to the output stream. </p>
  
  <p>I read entire input into buffer with </p>
  
  <pre><code>while (std::cin.get(c)) { }
  </code></pre>
  
  <p>After I write entire output to the stdout.</p>
  
  <p>Everything works fine when I run the application from command line eg <code>test.exe &lt; input.bin &gt; output.bin</code>, however this small app is supposed to be run from Python.</p>
  
  <p>I expect that Python <code>subprocess.communicate</code> is supposed to be used, the docs say: </p>
  
  <blockquote>
    <p>Interact with process: Send data to stdin. Read data from stdout and
    stderr, until end-of-file is reached. Wait for process to terminate.</p>
  </blockquote>
  
  <p>So <code>communicate()</code> will wait until the end-of-file before waiting my app to finish - is EOF supposed to happen when my application exits? Or should I explicitly do fclose(stderr) and fclose(stdout)?</p>