Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-07-19 23:04:48 +0200
committerErich Eckner <git@eckner.net>2017-07-19 23:04:48 +0200
commit5b54de944fd0e6fbfba515abf1d88140ac49c764 (patch)
treef4d671554f50c509085171aeca523691f1fbad3e /bin
parent2f04174266c375f5b4803f1dd346b61de0b63a64 (diff)
bin/show-dependencies: add lock
Diffstat (limited to 'bin')
-rwxr-xr-xbin/show-dependencies25
1 files changed, 24 insertions, 1 deletions
diff --git a/bin/show-dependencies b/bin/show-dependencies
index b144936..e729f57 100755
--- a/bin/show-dependencies
+++ b/bin/show-dependencies
@@ -2,6 +2,8 @@
. "${0%/*}/../conf/default.conf"
+# Create a lock file.
+
if [ $# -eq 0 ]; then
broken="$(
ls "${work_dir}/package-states" | \
@@ -11,7 +13,26 @@ if [ $# -eq 0 ]; then
echo "${broken}" | \
sed 's|\(\.[^.]\+\)\{4\}$||'
)"
- exec "$0" ${broken}
+ "$0" ${broken}
+ exit $?
+fi
+
+if ps ax | \
+ grep -v grep | \
+ grep -v "^\s*$$\s" | \
+ grep -wF "$0$(
+ printf ' %s' "$@"
+ )"; then
+
+ >&2 echo $$
+ >&2 echo 'I was running already.'
+ exit
+fi
+
+exec 9> "${work_dir}/${0##*/}.lock"
+if ! flock -n 9; then
+ echo 'Cannot get lock.'
+ exit
fi
tmp_dir="$(mktemp -d)"
@@ -197,3 +218,5 @@ for target_package in "$@"; do
dot -Tpng -o "${output}" "${tmp_dir}/input" || continue
done
+
+rm "${work_dir}/${0##*/}.lock"