PDA

View Full Version : Does/can xbmc return other codes on quit reboot etc


adix
2009-04-26, 03:42
Hi sorry if i'm off the ball on this please correct me if i'm wrong, buts it's my understanding that on quit, reboot, shutdown etc xbmc returns a code i.e 0, 64, 65 depending on what the action is. For instance the case statement regulary used in xsession script seems to wait for 0), 64), 65) etc, shown below.

xbmc --standalone
case "$?" in
0 ) # Quit
touch /tmp/noRestartXBMC
break ;;
64 ) # Shutdown System
sleep 10 ;;
65 ) # Warm Reboot
echo "Restarting XBMC ..." ;;
66 ) # Reboot System
sleep 10 ;;
* ) ;;
esac


basically i was wondering if someone could give me some further insight or point me in the direction of some documentation into the codes that are returned. I was mainly interested if there any other possible codes returned for other different behaviours such as logoff etc

cheers

adix
2009-04-28, 21:45
ok then - no one got any thoughts on that.

maybe someone could help on a very much related problem. I use the familar .xsession script. Basically i would like xbmc to restart when it crashes. however if i select exit i want it to start gnome. The script below does start gnome when select exit, fine but when it crashes it also starts gnome.

Is there a way we can distinguish between a crash and a manual exit?

#!/bin/bash

export XBMC_PLATFORM_MODE=1

while true
do
/usr/local/xbmc_270409c2/bin/xbmc-standalone
case "$?" in
0 ) # Quit
touch /tmp/LoadGnome
break 2 ;;
64 ) # Shutdown System
sleep 10 ;;
65 ) # Warm Reboot
echo "Restarting XBMC ..." ;;
66 ) # Reboot System
sleep 10 ;;
* ) ;;
esac
#if [ -e /tmp/LoadGnome ] ; then
# break
#fi

done


if [ -e /tmp/LoadGnome ] ; then
rm /tmp/LoadGnome
exec gnome-session
fi

topfs2
2009-04-29, 00:15
The exit codes can be viewed in xbmc/ApplicationMessenger.cpp and in method ProcessMessage()

Cheers,
Tobias

bobb0
2009-04-29, 05:41
adix,

the "recommended" way to run xbmc is to create a user for xbmc and configure gdm to autologin that user (preferences>login window.) the .xsession for that user runs xbmc, but if you exit xbmc using the exit function (in which case .xsession touches a noRestartXbmc file and exits the script) the script ending causes the user to logout and gdm displays a login screen. usually when xbmc crashes (in my case anyway) it takes X with it, and the whole Xserver restarts rendering part of that chunk of .xsession script practically useless. on restart it drops to the login screen where i have it set to re-autologin after 10 seconds. i think the xsession script is still good for delaying the exit of .xsession when you are telling it to reboot or shutdown, but beyond that its not much help in terms of an xbmc crash in standalone mode. if its not running in standalone mode you might be able to -not- take X with it... i dunno, i'm still experimenting a bit, though i'm pretty happy with my current setup.. :)

yee379
2009-04-29, 08:02
i personally hate the overhead (and disk space for gnome) of gdm. considering i do nothing but run xbmc on my machine, i just hack rc.local into a while loop, with a suspend if xbmc is exited.

and yes, i do run X and xbmc as a non-priv user.

this works well for example, when i press power on my remote which just exits xbmc then suspends the pc.

so... i too would be interested in the actual exit codes of xbmc :)

topfs2
2009-04-29, 08:07
Quit = 0
Powerdown entire system = 64
Restart application = 65
Restart entire system = 66

Edit: If the problem is that you can't differentiate between Quit and segfault I believe seffault doesn't generate exitcode, hence you can create a script that does exit 12 wich you call before running XBMC, this will set errorcode to 12 and will stay that way if XBMC segfaulted

adix
2009-04-30, 21:43
hey guys thanks for your input.

I too do not like the overhead of gnome and actually have a dedicated xbmc partition without gdm etc and works fine. However i'm playing around to see if i can get xbmc as the default "dash" as such with the option to load something like gnome on exit without the overhead behind. the script above works except for crashes where it'll load gnome instead of xbmc. if i remove the touch and if statement it'll reload xbmc on crash fine.

@topfs2 or someone that understands topfs2 script idea.
Could you explain a bit more about what you mean by a script and exit 12 - i'm not too sure i understand. But saying that would something like this work?


while true
do

$?=12

/usr/local/xbmc_270409c2/bin/xbmc-standalone

case "$?" in
0 ) # Quit
touch /tmp/LoadGnome
break 2 ;;
64 ) # Shutdown System
sleep 10 ;;
65 ) # Warm Reboot
echo "Restarting XBMC ..." ;;
66 ) # Reboot System
sleep 10 ;;
* ) ;;
esac
done