X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsynfigstudio-cph-monitor;h=6dcc2bc12f7d9e37dd906a7c21c5e82aba4de307;hb=714ab44cd605f122ef1cf311eb301f74f246f71a;hp=76f77f4638a4c0380484b94966b18d47e5a368cb;hpb=0a146b70060f29b894a369af20396d7f4246d107;p=synfig.git diff --git a/synfig-studio/trunk/synfigstudio-cph-monitor b/synfig-studio/trunk/synfigstudio-cph-monitor index 76f77f4..6dcc2bc 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() @@ -98,13 +118,13 @@ dumpstats() mainloop() { while true; do - if ( ps -f -u `whoami`|egrep "synfigstudio$" >/dev/null ) ; then + if ( ps --no-headers -f -Csynfigstudio |egrep "^`whoami`" > /dev/null ) ; then #synfigstudio process exist if [[ $STARTED == 0 ]]; then STARTED=1 RUNTIME=0 #get version - P=$(ps -f -u `whoami`|egrep "synfigstudio$"| tr -s ' '| cut -d ' ' -f 8) + P=$(ps --no-headers -f -Csynfigstudio |egrep "^`whoami`" | tr -s ' '| cut -d ' ' -f 8) echo if [ ! -e $P ]; then P=`which $P` @@ -138,5 +158,6 @@ mainloop() done } + init mainloop