]> code.ossystems Code Review - openembedded-core.git/commitdiff
build-perf-test-wrapper.sh: implement locking
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 2 Feb 2017 10:42:12 +0000 (12:42 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 2 Feb 2017 17:37:36 +0000 (17:37 +0000)
In order to prevent multiple instances of the script running at the same
time.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
scripts/contrib/build-perf-test-wrapper.sh

index e03ea978b9f441fce669f2ff696d6719795317e0..a4c19290a7f9ca2aa52c470482c608a7001805ad 100755 (executable)
@@ -67,6 +67,17 @@ if [ $# -ne 0 ]; then
     exit 1
 fi
 
+# Open a file descriptor for flock and acquire lock
+LOCK_FILE="/tmp/oe-build-perf-test-wrapper.lock"
+if ! exec 3> "$LOCK_FILE"; then
+    echo "ERROR: Unable to open lock file"
+    exit 1
+fi
+if ! flock -n 3; then
+    echo "ERROR: Another instance of this script is running"
+    exit 1
+fi
+
 echo "Running on `uname -n`"
 if ! git_topdir=$(git rev-parse --show-toplevel); then
         echo "The current working dir doesn't seem to be a git clone. Please cd there before running `basename $0`"