From 4615953ba4a3f56bfb6e4a658ce6b17a5a50ba2e Mon Sep 17 00:00:00 2001 From: "Tyler J. Wagner" Date: Sun, 25 Nov 2018 01:47:19 +0000 Subject: [PATCH] Fix bug: shutdown fails when ES not running This fixes a bug that prevents safe shutdown when EmulationStation is not running. The os.system() calls use && (logical and) statements, which require each command to return 0 on exit, or the next command won't be run. The "sudo killall emulationstation" fails when ES isn't running, such as when the user has pressed F4 to work at the terminal. Thus the system doesn't shut down. Using simple ";" statements sequences the commands without regard to exit status. --- SafeShutdown.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SafeShutdown.py b/SafeShutdown.py index 7d6393b..98276e0 100644 --- a/SafeShutdown.py +++ b/SafeShutdown.py @@ -16,11 +16,11 @@ #functions that handle button events def when_pressed(): led.blink(.2,.2) - os.system("sudo killall emulationstation && sleep 5s && sudo shutdown -h now") + os.system("sudo killall emulationstation ; sleep 5s ; sudo shutdown -h now") def when_released(): led.on() def reboot(): - os.system("sudo killall emulationstation && sleep 5s && sudo reboot") + os.system("sudo killall emulationstation ; sleep 5s ; sudo reboot") btn = Button(powerPin, hold_time=hold) rebootBtn = Button(resetPin)