Advanced Launcher Terminating not Suspending when loading rom?

Im currently using Lordhasram’s Janurary build of Retroarch for Openelec along with Advanced Launcher but i have noticed on exit a game instead of being taken back to the rom list within Advanced Launcher im taken back to the Kodi main menu screen, so i believe Advanced Launcher is being terminated and not suspended on the launch of RetroArch. This is the script for the retroarch.sh file…

#!/bin/sh
ADDON_DIR=$HOME/.kodi/addons/emulator.retroarch
ADDON_FILES=/storage/emulators/retroarch
ADDON_CORES=$ADDON_DIR/cores
LD_LIBRARY_PATH=$ADDON_DIR/lib

if [ ! "$#" = "2" ];
then
  echo "Usage: `basename $0` core /path/to/romfile"
  echo "Example: `basename $0` snes9x /storage/mario.sfc"
  echo
  echo "Available cores:"
  echo " `ls -1 $ADDON_CORES/*.so  |  cut -d - -f 1 | cut -d / -f 7`"
  echo
  exit 1
fi

if [ ! -f $ADDON_CORES/$1_libretro.so ]; then
  echo "Core $1 not found, exiting."
  exit 1
fi

if [ ! -f "$2" ]; then
  echo "Rom file $2 not found, exiting."
  exit 1
fi

if [ -f "$2.cfg" ]; then
  echo "Config file for `basename "$2"` found, using."
  EXTRAFLAG="--appendconfig "$2.cfg""
fi

touch /var/lock/kodi.disabled
systemctl stop kodi

$ADDON_DIR/bin/retroarch -c $ADDON_FILES/configs/retroarch.cfg $EXTRAFLAG -L $ADDON_CORES/$1_libretro.so "$2" &

pid=$!
while kill -0 $pid >/dev/null
  do
    usleep 200000
  done

rm /var/lock/kodi.disabled
systemctl start kodi

It has been suggested to me to change the last few lines of the script from…

touch /var/lock/kodi.disabled
systemctl stop kodi

$ADDON_DIR/bin/retroarch -c $ADDON_FILES/configs/retroarch.cfg $EXTRAFLAG -L $ADDON_CORES/$1_libretro.so "$2" &

pid=$!
while kill -0 $pid >/dev/null
  do
    usleep 200000
  done

rm /var/lock/kodi.disabled
systemctl start kodi

to…

pgrep kodi.bin | xargs kill -SIGSTOP
sleep 1
$ADDON_DIR/bin/retroarch -c $ADDON_FILES/config/retroarch.cfg $EXTRAFLAG -L $ADDON_CORES/$1_libretro.so "$2" &
while [ $(pidof retroarch) ];do
usleep 200000
done;
pgrep kodi.bin | xargs kill -SIGCONT

Which i have done but when i do this no games load in Advanced Launcher anymore. I used PuTTY to load up a rom to see what was going on, so i used the command…

/storage/.kodi/addons/emulator.retroarch/bin/retroarch.sh nestopia "/var/media/Media Drive/ROMS/NES/Track & Field (USA).nes"

and got an error message, “Permission denied” so i allowed permissions via the following command…

chmod +x /storage/.kodi/addons/emulator.retroarch/bin/retroarch.sh

and then tried to run the command to load a rom again but now i get this error message, “’-sh: /storage/.kodi/addons/emulator.retroarch/bin/retroarch.sh: not found”.

Any ideas why im getting these error messages at all?, I can load into the RGUI menu just fine however by typing…

/storage/.kodi/addons/emulator.retroarch/bin/retroarch --config /storage/emulators/retroarch/configs/retroarch.cfg --menu

Also take extra notice that for some reason in Lordhasram’s build the ‘Config’ file has an ‘s’ on the end so its actually ‘Configs’, which had me stumped for ages as i couldnt get any configurations to be saved, not sure why his build has the wrong name for the config folder??

Any help in getting Advanced Launcher to work with Ra would be much appreciated