title: Will flock'ed file be unlocked when the process die unexpectedly?
body: <p>Following this <a href="https://stackoverflow.com/a/1780878/88597">answer</a> to limit only one instance of a php script running:</p>
  
  <pre><code>&lt;?php
  
    $fp = fopen("/tmp/one.txt", "r+");
    if (flock($fp, LOCK_EX)) {
      //
      do_something_lengthy();
      //
      flock($fp, LOCK_UN);
    } else {
      echo "Couldn't get the lock!";
    }
  
    fclose($fp);
  
  ?&gt;
  </code></pre>
  
  <p>My question is, will the <code>flock</code>'ed one.txt file be unlock if the process die in the middle of <code>do_something_lengthy()</code>, i.e. before calling <code>flock($fp, LOCK_UN)</code>?</p>