summaryrefslogtreecommitdiff
path: root/lib/common-functions
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-05-25 09:07:39 +0200
committerErich Eckner <git@eckner.net>2018-05-25 09:07:39 +0200
commit0be03e8056755deaaf1492fa1df38907eade690e (patch)
treeef9a485711a1b098c249c1494ffc3029cc8da728 /lib/common-functions
parentad863c02e7b0e7030a920a318fcb9a9963333eb3 (diff)
downloadbuilder-0be03e8056755deaaf1492fa1df38907eade690e.tar.xz
verbose_flock new: it calls flock and reports about blocking processes on error
Diffstat (limited to 'lib/common-functions')
-rwxr-xr-xlib/common-functions15
1 files changed, 15 insertions, 0 deletions
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}
+ }
+}