package/rpcbind: fix musl build
[buildroot-gz.git] / package / kodi / br-kodi
blob83d4d4e5ac3b5e845bc43ecc28768db2325a1923
1 #!/bin/sh
3 # We're called with the real Kodi executable as
4 # first argument, followed by any Kodi extra args
5 KODI="${1}"
6 shift
8 # In case someone asked we terminate, just kill
9 # the Kodi process
10 trap_kill() {
11 LOOP=0
12 killall "${KODI##*/}"
14 trap trap_kill INT QUIT TERM
16 LOOP=1
17 while [ ${LOOP} -eq 1 ]; do
18 # Hack: BusyBox ash does not catch signals while a non-builtin
19 # is running, and only catches the signal when the non-builtin
20 # command ends. So, we just background the Kodi binary, and wait
21 # for it. But BusyBox' ash's wait builtin does not return the
22 # exit code even if there was only one job (which is correct
23 # for POSIX). So we explicitly wait for the Kodi job
24 "${KODI}" "${@}" &
25 wait %1
26 ret=$?
27 case "${ret}" in
28 0) ;;
29 64) poweroff; LOOP=0;;
30 66) reboot; LOOP=0;;
31 *) # Crash
32 sleep 1
34 esac
35 done
36 exit ${ret}