Module: synfig
Branch: zelgadis_master
Commit: f0b3a083d6ebf2080c85696b2867f019d9a97fa9
URL:    
http://synfig.git.sourceforge.net/git/gitweb.cgi?p=synfig;a=commit;h=f0b3a083d6ebf2080c85696b2867f019d9a97fa9

Author: Konstantin Dmitriev <ksee.zelga...@gmail.com>
Date:   Mon Jul 27 18:29:08 2009 +0700

Forbid double run of synfigstudio-cph-monitor.

---

 synfig-studio/trunk/synfigstudio-cph-monitor |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/synfig-studio/trunk/synfigstudio-cph-monitor 
b/synfig-studio/trunk/synfigstudio-cph-monitor
index 000b83a..7ca8461 100755
--- a/synfig-studio/trunk/synfigstudio-cph-monitor
+++ b/synfig-studio/trunk/synfigstudio-cph-monitor
@@ -17,10 +17,9 @@ trap writelog INT
 
 init()
 {
-echo "Synfig Crash Monitor is a tool to collect statistics about synfig 
crashes."
+echo "SynfigStudio Crash Monitor is a tool to collect statistics about synfig 
crashes."
 echo "All information is collected locally in ~/.synfig/cph directory."
 echo
-echo `date +%H:%M` "Synfig Crash Monitor started."
 STARTED=0
 RUNTIME=0
 VERSION=''
@@ -29,6 +28,27 @@ BRANCH=''
 REVISION_ID=''
 CRASH=0
 [ ! -d ~/.synfig/cph ] && mkdir -p ~/.synfig/cph || true
+
+# Detect if crash monitor is already started
+PDIR=${0%`basename $0`}
+LCK_FILE=~/.synfig/cph/`basename $0`.lck
+if [ -f "${LCK_FILE}" ]; then
+       MYPID=`head -n 1 "${LCK_FILE}"`
+       if ! ( ps -p ${MYPID} | grep ${MYPID} >/dev/null ); then
+               # The process is not running
+               # Echo current PID into lock file
+               echo $$ > "${LCK_FILE}"
+       else
+               echo "`basename $0` is already running [${MYPID}]. Aborting."
+               sleep 5
+               exit 0
+       fi
+else
+       # The process is not running
+       # Echo current PID into lock file
+       echo $$ > "${LCK_FILE}"
+fi
+echo `date +%H:%M` "Synfig Crash Monitor started."
 }
 
 writelog()
@@ -143,5 +163,6 @@ mainloop()
        done
 }
 
+
 init
 mainloop


------------------------------------------------------------------------------
_______________________________________________
Synfig-devl mailing list
Synfig-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to