Skip to content

Instantly share code, notes, and snippets.

@asgrim
Created July 9, 2014 10:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save asgrim/fdaa1ebe70d883ba581f to your computer and use it in GitHub Desktop.
<?php
$flockHandle = fopen('/tmp/blah.lock', 'w');
if (!flock($flockHandle, LOCK_EX | LOCK_NB))
{
echo "Cannot get lock.";
die();
}
// do something
flock($flockHandle, LOCK_UN);
fclose($flockHandle);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment