aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authoralthekiller <althekiller@svn>2009-12-31 03:06:38 +0000
committeralthekiller <althekiller@svn>2009-12-31 03:06:38 +0000
commite3b18b2a4cc636e8d7bbd83997b53e985d0ea666 (patch)
tree48cd0cd48e02ae15cff45a8af1b6dee6bb5fe178 /tools
parent7d8044e94dde82195be12844ae4e453840fe35c6 (diff)
added: [LINUX] xbmc-standalone wrapper script to restart XBMC on crash so long as it hasn't happened more than three times in the last minute.
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@26211 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'tools')
-rwxr-xr-xtools/Linux/xbmc-standalone.sh33
-rw-r--r--tools/Linux/xbmc.sh.in8
2 files changed, 35 insertions, 6 deletions
diff --git a/tools/Linux/xbmc-standalone.sh b/tools/Linux/xbmc-standalone.sh
index 146b3e0ba2..e5917f9887 100755
--- a/tools/Linux/xbmc-standalone.sh
+++ b/tools/Linux/xbmc-standalone.sh
@@ -1,6 +1,33 @@
-#!/bin/sh
+#!/bin/bash
if which pulse-session; then
- pulse-session xbmc --standalone "$@"
+ XBMC="pulse-session xbmc --standalone \"$@\""
else
- xbmc --standalone "$@"
+ XBMC="xbmc --standalone \"$@\""
fi
+
+LOOP=1
+CRASHCOUNT=0
+LASTSUCCESSFULSTART=$(date +%s)
+ulimit -c unlimited
+while (( $LOOP ))
+do
+ $XBMC
+ RET=$?
+ NOW=$(date +%s)
+ if (( ($RET >= 64 && $RET <=66) || $RET == 0 )); then # clean exit
+ LOOP=0
+ else # crash
+ DIFF=$((NOW-LASTSUCCESSFULSTART))
+ if (($DIFF > 60 )); then # Not on startup, ignore
+ LASTSUCESSFULSTART=$NOW
+ CRASHCOUNT=0
+ else # at startup, look sharp
+ CRASHCOUNT=$((CRASHCOUNT+1))
+ if (($CRASHCOUNT >= 3)); then # Too many, bail out
+ LOOP=0
+ echo "XBMC has exited uncleanly 3 times in the ${DIFF}s. Something is probably wrong"
+ fi
+ fi
+ fi
+done
+
diff --git a/tools/Linux/xbmc.sh.in b/tools/Linux/xbmc.sh.in
index 0a10b832b5..aa49bd48b0 100644
--- a/tools/Linux/xbmc.sh.in
+++ b/tools/Linux/xbmc.sh.in
@@ -69,7 +69,7 @@ fi
python @prefix@/share/xbmc/FEH.py "$@"
if [ $? -ne 0 ]; then
- exit
+ exit 0
fi
LOOP=1
ulimit -c unlimited
@@ -79,11 +79,13 @@ do
@prefix@/share/xbmc/xbmc.bin "$@"
RET=$?
if (( $RET == 65 ))
- then
+ then # User requested to restart app
LOOP=1
elif (( ($RET >= 131 && $RET <= 136) || $RET == 139 ))
- then
+ then # Crashed with core dump
print_crash_report
fi
done
+exit $RET
+