buildrootschalter/package/xbmc/br-xbmc
Yann E. MORIN 04be2f426f package/xbmc: use poweroff to poweroff the RPi
Using "poweroff" instead of "halt" has the side advantage of flashing
the "ACT" LED 10 times (@ ~1Hz) to instruct the user when it is safe
to unplug the power supply.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2014-06-08 15:48:05 +02:00

37 lines
929 B
Bash
Executable File

#!/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) poweroff; LOOP=0;;
66) reboot; LOOP=0;;
*) # Crash
sleep 1
;;
esac
done
exit ${ret}