A simple lock file library.
Provides mutual exclusion for scripts that require the same resource.
Requires three additional lines of code in your script, including sourcing the library.
Scripts using Keyway can be configured to either terminate or busy-wait if a resource is blocked.
Keyway will report when an external error was caught and there are lock files in the lock directory.
acquire_lock_for "your_task_name"
acquire_spinlock_for "your_task_name"
Your application was not able to acquire lock.
There was some other problem:
Keyway could not create the lock directory.
Keyway could not create or remove a lock.
An error was caught and there are lock files in the lock directory.
#!/bin/bash source keyway_lib.sh # optionally override the lock file directory LOCK_DIR="alt-lock-dir" # attempt to lock the shared resource acquire_lock_for "your_task_name" # if the lock was successful, execute the task echo "executing critical section" # release the lock when the task is done release_lock_for "your_task_name"