Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A file-based locking primitive which provides mutual exclusion between unrelated processes and threads
C
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
Doxyfile
LICENSE
Makefile
README.md
safelock-example.c
safelock.c
safelock.h

README.md

Safelock

Safelock is a file-based locking primitive which provides mutual exclusion between unrelated processes and threads.

Safelock offers advantages over POSIX and BSD file locks such as:

  • Compatible with multi-threaded applications
  • Support for lock attempt timeouts
  • Detection of crashed lock holders
  • Detailed lock status (PID, lock age, custom data)

Safelock requires POSIX.1-2008 robust mutexes. Tested under Linux 2.6.32 and Solaris 11.

Review safelock.h or http://mpx.github.com/safelock/ for detailed documentation.

License: MIT

Mark Pulford <mark@kyne.com.au>

Example

#include "safelock.h"
...
safelock_t lock;
err = safelock_open(&lock, "lock.dat", 0660);
err = safelock_lock(lock, SAFELOCK_LOCK_WAIT, 42);
...
err = safelock_unlock(lock);
err = safelock_close(&lock);
Something went wrong with that request. Please try again.