summaryrefslogtreecommitdiffstats
path: root/package/xbmc/br-xbmc
diff options
context:
space:
mode:
Diffstat (limited to 'package/xbmc/br-xbmc')
-rwxr-xr-xpackage/xbmc/br-xbmc36
1 files changed, 36 insertions, 0 deletions
diff --git a/package/xbmc/br-xbmc b/package/xbmc/br-xbmc
new file mode 100755
index 0000000000..2a62b31bb6
--- /dev/null
+++ b/package/xbmc/br-xbmc
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# We're called with the real XBMC executable as
+# first argument, followed by any XBMC extra args
+XBMC="${1}"
+shift
+
+# In case someone asked we terminate, just kill
+# the XBMC process
+trap_kill() {
+ LOOP=0
+ killall "${XBMC##*/}"
+}
+trap trap_kill INT QUIT TERM
+
+LOOP=1
+while [ ${LOOP} -eq 1 ]; do
+ # Hack: Busybox ash does not catch signals while a non-builtin
+ # is running, and only catches the signal when the non-builtin
+ # command ends. So, we just background the XBMC binary, and wait
+ # for it. But Busybox' ash's wait builtin does not return the
+ # exit code even if there was only one job (which is correct
+ # for POSIX). So we explicitly wait for the XBMC job
+ "${XBMC}" "${@}" &
+ wait %1
+ ret=$?
+ case "${ret}" in
+ 0) ;;
+ 64) halt; LOOP=0;;
+ 66) reboot; LOOP=0;;
+ *) # Crash
+ sleep 1
+ ;;
+ esac
+done
+exit ${ret}
OpenPOWER on IntegriCloud