title: Python:How os.fork() works?
body: <p>I am learning multiprocessing in python. I tried multiprocessing and after I read the source code of multiprocessing module, I found it use <code>os.fork()</code>, so I wrote some code to test <code>os.fork()</code>, but I am stuck. My code is as following:</p>
  
  <pre><code>#!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  import os
  import time
  
  for i in range(2):
      print '**********%d***********' % i
      pid = os.fork()
      print "Pid %d" % pid
  </code></pre>
  
  <p>I think that each print will be executed two times but they execute three times. I can't understand how this works?
  I read this <a href="https://stackoverflow.com/questions/6011635/need-to-know-how-fork-works">Need to know how fork works?</a><br>
  From what this article says it also will be executed twice, so I am so stuck...</p>