Skip to content

Instantly share code, notes, and snippets.

@iarna
Created August 15, 2014 22:15
Show Gist options
  • Save iarna/bd63a8b6cdb0dbebbab5 to your computer and use it in GitHub Desktop.
Save iarna/bd63a8b6cdb0dbebbab5 to your computer and use it in GitHub Desktop.
  1. Create a lockname.pid file.
  2. Readdir, looking for lockname.* files:
  3. If found file pid is < our pid, and it is alive/not stale, FAIL and unlink our lockfile
  4. If we make it through, we have the lock, continue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment