title: fork() and output
body: <p>I have a simple program:</p>
  
  <pre><code>int main()
  {
      std::cout &lt;&lt; " Hello World";
      fork();
  }
  </code></pre>
  
  <p>After the program executes my output is: <code>Hello World Hello World</code>. Why does this happen instead of a single <code>Hello world</code>? I'm guessing that the child process is rerun behind the scenes and the output buffer is shared between the processes or something along those lines, but is that the case or is something else happening?</p>