From 09ef38e27765724df5690f30f77b425920d2619a Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Mon, 12 Feb 2024 00:29:35 +0100 Subject: [PATCH] Small fix. --- build.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index bf586fa..b77ad76 100644 --- a/build.sh +++ b/build.sh @@ -79,10 +79,12 @@ fi # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Mutex # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +readonly SIGNATURE="$(date +"%s")-$$" readonly LOCK_FILE="${BASE_DIR}/build/lockfile.${MY_CPU}" readonly TEMP_FILE="$(mktemp /tmp/lockfile_XXXXX)" -echo "$$" > "${TEMP_FILE}" && mv -n "${TEMP_FILE}" "${LOCK_FILE}" -if [ "$(cat "${LOCK_FILE}")" != "$$" ] ; then +printf "%s" "${SIGNATURE}" > "${TEMP_FILE}" +mv -n "${TEMP_FILE}" "${LOCK_FILE}"; rm -f "${TEMP_FILE}" +if [ "$(sed '/^$/d' "${LOCK_FILE}" | head -n1)" != "${SIGNATURE}" ] ; then echo 'Error: Build process is already in progress !!!' exit 1 fi