commit 62e232ef76fe95a30283b35dd56f09cc98a11416
parent 59976671f934151f1a1b55266f34ac930cdbacbf
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date: Tue, 15 Dec 2015 12:59:18 +0100
prevent overwriting existing pid
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sbin/snap.lvm2 b/sbin/snap.lvm2
@@ -13,7 +13,10 @@ export SNAPSHOT
LOCKDIR=/var/lock/snaprep
test -d "$LOCKDIR" || mkdir -p "$LOCKDIR" || exit $?
LOCKFILE="$LOCKDIR/lvm2.${SRC//\//-}"
-# exec 3> "$LOCKFILE" || exit $?
+if ! flock -n "$LOCKFILE"; then
+ echo >&2 "locked: $SRC"
+ exit 1
+fi
(
flock -n 3 || exit $?
echo $$ >&3