From 0be03e8056755deaaf1492fa1df38907eade690e Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 25 May 2018 09:07:39 +0200 Subject: verbose_flock new: it calls flock and reports about blocking processes on error --- lib/common-functions | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/common-functions') diff --git a/lib/common-functions b/lib/common-functions index 4224831..b152f53 100755 --- a/lib/common-functions +++ b/lib/common-functions @@ -719,3 +719,18 @@ calculate_script_checksum() { sha512sum | \ awk '{print $1}' } + +# verbose_flock +# flock wrapper with some informational output on error +verbose_flock() { + local err=0 + flock "$@" || { + err=$? + lsof "/proc/$$/fd/$( + printf '%s\n' "$@" | \ + grep -vm1 '^-' + )" || true + printf 'FYI: I am %s.\n' "$$" + return ${err} + } +} -- cgit v1.2.3