From e52d65e4d89b188059926db8fb066fd90a2279ab Mon Sep 17 00:00:00 2001 From: Michael Monreal Date: Thu, 12 Aug 2010 09:42:22 +0100 Subject: [PATCH] [cli] remove pid file when sparkleshare isn't running --- AUTHORS | 1 + SparkleShare/sparkleshare.in | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 9507963b..8f845076 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,6 +13,7 @@ Contributors: Jakub Steiner Lapo Calamandrei Łukasz Jernaś + Michael Monreal Oleg Khlystov Philipp Gildein Ruben Vermeersch diff --git a/SparkleShare/sparkleshare.in b/SparkleShare/sparkleshare.in index 6a5e559d..ea373c17 100644 --- a/SparkleShare/sparkleshare.in +++ b/SparkleShare/sparkleshare.in @@ -27,11 +27,17 @@ case $1 in ;; stop) - if [ -e "/tmp/sparkleshare/sparkleshare.pid" ]; then - echo -n "Stopping SparkleShare..." - kill `cat /tmp/sparkleshare/sparkleshare.pid` - rm -f /tmp/sparkleshare/sparkleshare.pid - echo " Done." + if [ -e "${pidfile}" ]; then + sparklepid=`cat ${pidfile}` + if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then + echo -n "Stopping SparkleShare..." + kill ${sparklepid} + rm -f ${pidfile} + echo " Done." + else + echo "SparkleShare isn't running, removing stale pid file" + rm -f ${pidfile} + fi else echo "SparkleShare isn't running." fi @@ -67,4 +73,5 @@ case $1 in *) echo "Usage: sparkleshare {start|stop|restart|help}" ;; + esac