From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 64560158018 for ; Sun, 3 Oct 2021 04:01:13 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C75BDE086C; Sun, 3 Oct 2021 04:01:10 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 52243E0858 for ; Sun, 3 Oct 2021 04:01:10 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 20579342B2A for ; Sun, 3 Oct 2021 04:01:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 92F1811C for ; Sun, 3 Oct 2021 04:01:07 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1633225385.6f6354f622ef92418cfd3f111064c37d4a6cd6c9.vapier@gentoo> Subject: [gentoo-commits] proj/build-docbook-catalog:master commit in: / X-VCS-Repository: proj/build-docbook-catalog X-VCS-Files: build-docbook-catalog X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 6f6354f622ef92418cfd3f111064c37d4a6cd6c9 X-VCS-Branch: master Date: Sun, 3 Oct 2021 04:01:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 240b268d-8056-4cb7-8f74-6b9696afd48f X-Archives-Hash: 1eaaf88753b8d25ba626a19038beca2c commit: 6f6354f622ef92418cfd3f111064c37d4a6cd6c9 Author: Mike Frysinger gentoo org> AuthorDate: Sun Oct 3 01:43:05 2021 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sun Oct 3 01:43:05 2021 +0000 URL: https://gitweb.gentoo.org/proj/build-docbook-catalog.git/commit/?id=6f6354f6 switch locking to flock If the tool gets killed while holding its lock, the files stay locked, and future runs hang waiting for the lock, until a dev manually clears things. Switch to flock as it provides a process-based lock and the kernel will release it automatically when we exit. Signed-off-by: Mike Frysinger gentoo.org> build-docbook-catalog | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/build-docbook-catalog b/build-docbook-catalog index b815bfc..b4d7223 100755 --- a/build-docbook-catalog +++ b/build-docbook-catalog @@ -69,14 +69,11 @@ main() { mkdir -p "${ROOT}${ROOTCONFDIR}" || error "could not create ${ROOTCONFDIR}" fi - local lock="${ROOT}${ROOTCONFDIR}"/build-docbook-catalog-lock + local lock="${ROOT}/run/lock/build-docbook-catalog.lock" ( # Lock the dir to avoid trashing other runs that might # be running parallel. - touch "${lock}".$$ && \ - until ln "${lock}".$$ "${lock}" 2>/dev/null; do sleep 1; done && \ - rm "${lock}".$$ - [[ -f ${lock}.$$ ]] && error "unable to lock ${ROOTCONFDIR}" + flock 200 create_catalogs # will exit on error for type in xsl xsl-ns xsl-saxon xsl-xalan; do @@ -98,8 +95,9 @@ main() { populate_entities fi - ) - rm "${lock}" + # NB: Don't delete the lock since we can't delete files by fd, and if we do + # it by path, we might delete the lock while other processes grab it. + ) 200>>"${lock}" exit 0 }