From: Silvio Rhatto Date: Sun, 27 Feb 2011 03:46:25 +0000 (-0300) Subject: Lockfile enhancement at check-puppetd X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=4bd5435cab38818318818906c5f864a599990e26;p=puppet-puppet.git Lockfile enhancement at check-puppetd --- 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