From 105a20a032b5b458c85d946fdec0f862f8c0f7e2 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Tue, 12 Nov 2024 08:21:14 +0800 Subject: [PATCH] My lock got stuck --- lib/include/build_lock.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/include/build_lock.sh b/lib/include/build_lock.sh index bf5660e..150405b 100644 --- a/lib/include/build_lock.sh +++ b/lib/include/build_lock.sh @@ -85,12 +85,22 @@ function _cleanup_stale_locks() { path="$(printf '%s\n' "$lock_entry" | awk '{ print $1 }')" uuid="$(printf '%s\n' "$lock_entry" | awk '{ print $2 }')" pid="$(printf '%s\n' "$lock_entry" | awk '{ print $3 }')" + + if [ "$pid" = "" ] + then + wrn "WARNING: the lock owner pid is empty. This is a bug!" + wrn " please check build_lock.sh and add some cleanup code" + return + fi + if ! ps "$pid" >/dev/null then wrn "WARNING: the pid $pid holding the build lock is not running" wrn " removed the lock entry ..." _remove_build_lock "^$path $uuid $pid " + else + log "the pid '$pid' is holdig the lock and still running" fi done < "$BUILD_LOCKFILE" }