From 7381abdac347652dbe78cfa6f2a1da417f6dec55 Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Sat, 14 Feb 2015 09:40:12 +0100 Subject: [PATCH] Replaced flocking again with mkdir lock to prevent leaking file descriptors when calling lv commands. --- backmeupscotty | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/backmeupscotty b/backmeupscotty index e0689a0..e17a4c6 100644 --- a/backmeupscotty +++ b/backmeupscotty @@ -125,6 +125,12 @@ function scottysync { done } +function deleteLock { + if ! rmdir /tmp/$(basename $0).lock; then + scottyerror "Could not delete lockfile /tmp/$(basename $0).lock!" + fi +} + function cleanup_abort { scottyerror "Caught exit signal! Cleaning up." @@ -135,6 +141,8 @@ function cleanup_abort { kill $(jobs -p) fi + deleteLock + exit } @@ -146,6 +154,11 @@ function prepare { scottyinfo "No prepare function was defined." } +function cleanup_normal { + cleanup + deleteLock +} + function printhelp { cat </var/run/$(basename $0).pid -if ! flock -n 200; then +if ! mkdir /var/run/$(basename $0).lock; then scottyerror "Another instance of $(basename $0) is still running!" exit 1 +else + trap deleteLock EXIT fi -echo $$ 1>&200 -- 2.39.5