title: What is the difference between locking with `fcntl` and `flock`?
body: <p>I'm reading for hours but can't understand what is the <strong>difference</strong> between the two locks. The only thing I understand is that <code>fcntl()</code> lock is offering a granular lock that can lock specific bytes and that only <code>fcntl()</code> supports NFS locking.</p>
  
  <p>It's said that the difference is in their semantics, how do they behave when being duplicated by <code>dup()</code> or while <code>fork()</code>, but I can't understand what is the difference in practice.</p>
  
  <p>My scenario is that I'm writing to a log file in a <code>fork()</code> based server, where every forked process is writing to the same file when <em>something</em> happens. Why would I want to use <code>flock()</code> and why would I want to use <code>fcntl()</code> locks?</p>