From 4bd5435cab38818318818906c5f864a599990e26 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 27 Feb 2011 00:46:25 -0300 Subject: Lockfile enhancement at check-puppetd --- templates/check-puppetd.sh.erb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'templates') diff --git a/templates/check-puppetd.sh.erb b/templates/check-puppetd.sh.erb index 1340315..d467ad6 100644 --- a/templates/check-puppetd.sh.erb +++ b/templates/check-puppetd.sh.erb @@ -49,14 +49,18 @@ function check_lockfile { local pid process if [ ! -z "$LOCKFILE" ] && [ -f "$LOCKFILE" ]; then - pid="`cat $LOCKFILE`" + pid="`cat $LOCKFILE 2> /dev/null`" process="`ps --no-headers -o comm $pid`" - if [ "$?" == "0" ] && [ "`ps --no-headers -o comm $$`" == "$process" ]; then - echo "Another backup is running for $LOCKFILE, skipping run" - exit - else - echo "Found old lockfile $LOCKFILE, removing it" - unset_lockfile + + # Check lockfile again + if [ -f "$LOCKFILE" ]; then + if [ "$?" == "0" ] && [ "`ps --no-headers -o comm $$`" == "$process" ]; then + echo "Another backup is running for $LOCKFILE, skipping run" + exit + else + echo "Found old lockfile $LOCKFILE, removing it" + unset_lockfile + fi fi fi -- cgit v1.2.3