Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Shutdown Script Emulator Sceleton
- # by cyperghost for retropie
- # --------------------------
- # Initial release: ??? Don't know January 2018?
- # 04/19/18 Release in RetroPie forums
- # 04/20/18 julenvitoria introduced kill -9 signal for emulators
- # This function is called still all childPIDs are found
- function getcpid() {
- local cpids="$(pgrep -P $1)"
- for cpid in $cpids;
- do
- pidarray+=($cpid)
- getcpid $cpid
- done
- }
- # Abolish sleep timer! This one is much better!
- function smart_wait() {
- local PID=$1
- while [[ -e /proc/$PID ]]
- do
- sleep 0.05
- done
- }
- # Our entrypoint! RUNCOMMAND is alpha, emulator is OMEGA
- motherpid="$(pgrep -f -n runcommand.sh)"
- # if there is no runcommand.sh running then exit
- [ "$motherpid" ] && getcpid $motherpid || exit
- # Reverse array and do your TERM job
- for ((z=${#pidarray[*]}-1; z>-1; z--)); do
- echo "Terminate PID ${pidarray[z]}"
- kill -9 ${pidarray[z]}
- smart_wait ${pidarray[z]}
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement