title: Perl File::NFSLock fails to acquire lock with error EACCESS
body: <p>I have a file on an NFS mount which is locked and unlocked for every operation done on it.
  Initially I used <code>flock(filehandle, LOCK_EX|LOCK_NB)</code> but that attempt failed with <code>I/O Error</code>.<br />
  On browsing through multiple forums I found a solution to use <code>File::NFSLock</code> to lock/unlock files on a NFS share. However, NFSLock succeeds on the first attempt to lock and unlock the file, however when 2 processes simultaneously tries to access the locks, it fails with <code>EACESS</code> error.<br />
  Here is how the code is:</p>
  <ol>
  <li><code>Process 1</code> acquired lock with the below code and also released the lock once done:</li>
  </ol>
  <pre><code>    if ($lock = new File::NFSLock {
        file      =&gt; $handle,
        lock_type =&gt; LOCK_EX|LOCK_NB,
      }) {
  </code></pre>
  <ol start="2">
  <li>Now 2 processes were spawned with a <code>fork</code> command (<code>Process 2</code> and <code>Process 3</code>). When <code>Process 2</code> tried to lock the same file using same above code in Step 1, file locking failed with error <code>Permission Denied</code>. After 15 seconds when <code>Process 3</code> tried to acquire lock it also failed with <code>Permission Denied</code> error.<br />
  When I executed <code>fuser -v</code> on the file, I could see 2 process IDs (<code>Process 2</code> and <code>Process 3</code>) which had opened the file for writing.</li>
  </ol>
  <p>Few documents on internet suggest that <code>The lock cannot be set because it is blocked by an existing lock on the file. Some systems use EAGAIN in this case, and other systems use EACCES</code> however doesn't seem to be the case in my scenario as <code>Process 1</code> had released the lock.<br />
  Also please note that all the 3 processes were spawned from the same script, so there shouldn't be an issue of different user trying to acquire the lock.</p>
  <p>Thank You!</p>