I am attempting to create a safe reset switch according to these instructions. I have implemented the interrupt-based solution (listing 1) which runs fine if I start the script from the command line, but I am unable to get it to work successfully when run from startup. The article was written prior to the implementation of systemd on the RPi, and the suggested use modifying rc.local is not working for me.
In debugging the command, I have found that the issue is with this portion of the script:
def loop(): raw_input()
The function is used to prevent the program from exiting without using a lot of system resources. Trying to start a service based upon a script with this command, however, fails. I am able to use the while loop in listing 2 in a script assigned to a service; however I'd like to avoid the loop if possible in order to minimize resource use.
Questions: (a) Is there a way to properly implement
raw_input() in a script to be called by a systemd service? (b) Are there other resource-light methods to prevent a python script from exiting?