title: file write lock and child process
body: <p>If a process give a file a write lock and then it spawn a child process, is lock inherited by the child process? If yes, then there is 2 process have the write lock, I learned that there is <em>only</em> 1 process can have a write lock, some truth? here is a test python code</p>
  
  <pre><code>#!/usr/bin/python
  
  import fcntl
  import time
  import os
  
  fp = open('test.ini','w')
  fcntl.flock(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
  pid = os.fork()
  
  if pid &gt; 0:
      time.sleep(10)
      exit(0)
  if pid == 0:
      time.sleep(100)
      exit(0)
  </code></pre>
  
  <p>when the parent exist, i tried to get the lock of file test.ini, but <em>failed</em>  , so I guess the child has the lock</p>