build-perf-test-wrapper.sh: implement locking

In order to prevent multiple instances of the script running at the same
time.

(From OE-Core rev: 96a194de890f7ef1e6e5e036b32848e0f9d1bcf5)

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Markus Lehtonen 2017-02-02 12:42:12 +02:00 committed by Richard Purdie
parent f1957bf59e
commit 42eace0770
1 changed files with 11 additions and 0 deletions

View File

@ -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`"