Mausberry Shutdown Script Doesn't Save Metadata
-
@cyperghost said in Mausberry Shutdown Script Doesn't Save Metadata:
@barrymossel Please can you use PID detector and check PIDs displayed?
Useps -a
and check PIDs?Sure, when I get back home. What do you want me to do exactly?
@meleu said in Mausberry Shutdown Script Doesn't Save Metadata:
@barrymossel and post the exact script you're using on ghostbin.com or something.
Sure, will do so in some hours.
-
- Post code of your current switch bash to ghostbin.com and give us the link
- Run emulator ScummVM
2.1 Connect with SSH
2.2 Check PIDs (Process ID) during emulator is running
2.2.1 Use PID Detector script
2.2.2ps - a
if PIDs are equal
if PID detector output one number and you type
kill PIDNUMBER
then the emulator should close :)Because you said your script (version 1.56) does not work with ScummVM so let us invetigate.
-
@cyperghost said in Mausberry Shutdown Script Doesn't Save Metadata:
- Post code of your current switch bash to ghostbin.com and give us the link
- Run emulator ScummVM
2.1 Connect with SSH
2.2 Check PIDs (Process ID) during emulator is running
2.2.1 Use PID Detector script
2.2.2ps - a
if PIDs are equal
if PID detector output one number and you type
kill PIDNUMBER
then the emulator should close :)Because you said your script (version 1.56) does not work with ScummVM so let us invetigate.
I actually didn't say it "doesn't work" with ScummVM. It just looks like it doesn't exit to ES first, but it looks like it goes straight to shutdown. I am just wondering if that is expected.
But I will do the above in a sec.
--- edit---
https://ghostbin.com/paste/jahru2335 vs. 2336
pi@retropie:~ $ bash pidtest.sh An emulator is currently running! It's PID is: 2335 EmulationStation is runnuning! ES's PID is: 1008 pi@retropie:~ $ ps -a PID TTY TIME CMD 992 tty1 00:00:00 bash 997 tty1 00:00:00 bash 998 tty1 00:00:00 emulationstatio 1005 tty1 00:00:00 emulationstatio 1008 tty1 00:00:46 emulationstatio 2245 tty1 00:00:00 sh 2246 tty1 00:00:00 bash 2335 tty1 00:00:00 bash 2336 tty1 00:00:21 scummvm 3415 pts/0 00:00:00 ps pi@retropie:~ $
And another test: 6901 vs 6902
pi@retropie:~ $ bash pidtest.sh An emulator is currently running! It's PID is: 6901 EmulationStation is runnuning! ES's PID is: 1008 pi@retropie:~ $ ps -a PID TTY TIME CMD 992 tty1 00:00:00 bash 997 tty1 00:00:00 bash 998 tty1 00:00:00 emulationstatio 1005 tty1 00:00:00 emulationstatio 1008 tty1 00:01:52 emulationstatio 6815 tty1 00:00:00 sh 6816 tty1 00:00:00 bash 6901 tty1 00:00:00 bash 6902 tty1 00:00:26 scummvm 8210 pts/0 00:00:00 ps pi@retropie:~ $
-
@barrymossel
You see PID Detector says an emulator is running with PID xxxx.What happens if you kill that PID with
kill xxxx
and can you also enter output ofps -a
after the kill command?The script is v 1.56! So it's the newest version.
-
pi@retropie:~ $ kill 6901 pi@retropie:~ $ ps -a PID TTY TIME CMD 992 tty1 00:00:00 bash 997 tty1 00:00:00 bash 998 tty1 00:00:00 emulationstatio 1005 tty1 00:00:00 emulationstatio 1008 tty1 00:01:54 emulationstatio 6902 tty1 00:01:00 scummvm 10250 pts/0 00:00:00 ps
So ScummVM keeps running. I guess, as expected.
-
@barrymossel That's interesting!
That's because ScummVM creates itself a bash call. -
@cyperghost said in Mausberry Shutdown Script Doesn't Save Metadata:
That's because ScummVM creates itself a bash call.
I would change this sentence to: "That's because runcommand starts ScummVM through a bash call."
;-)
-
@meleu Ready for quick'n'dirty coding? :)
what about a
kill $(expr $emupid + "1")
of course you check before if pid is active :) -
@cyperghost that behavior reported by @barrymossel was the reason why I was killing the emulator with
-9
(SIGKILL
). When you kill a bash script withSIGKILL
it kills all its child processes.But I realized that this isn't a good approach for retroarch, because it wouldn't save the
.srm
file...Looks like there are room for more improvements on that script. Will post something soon. (edit: or maybe you can do it yourself: just check if the first string on that 4th line is
bash
, if yes, kill the process with-9
) -
Ehm, I was wondering: does it even matter that ScummVM doesn't exit to ES before shutdown? Is there any ScummVM meta data anyway? Or wouldn't meta data from games you played before ScummVM be saved either?
-
@barrymossel said in Mausberry Shutdown Script Doesn't Save Metadata:
Or wouldn't meta data from games you played before ScummVM be saved either?
Yes for this question.
-
@meleu Hmm... and if you make case selection?
Are you sure there are no other caveeats? I must admit I'm not very common with the how to kill-a-process method.okay... I will try :)
It's not tested, i have no access to my Pi now... So just coded out of brain (Please make the code look better... I use lot's of ifs.... much to much!)emupid="$(sed -n 4p /dev/shm/runcommand.info | tr -d '\\"' | tr '^$[]*.()|+?{}' '.')" emu_com="$("${emupid%% *}")" emupid="$(pgrep -f "$emupid")" if [[ "$emu_com" == "bash" ]] && [[ "$emupid" ]]; then kill -9 $emupid && sleep 4 fi
You've to check also the PID.... because runcommand.info isn't deleted in ES caroussel mode after emulator is running :)
-
@barrymossel That's the question. You will losse all your progress in metadata saving if anything goes wrong.
But to be true.... I'm satisfied with 1.56 - the rest are rare usecases (imho)
-
@meleu
Annother suggestion[[ "$(ps -p $(expr $emupid + "1") -o comm=)" == "scummvm" ]] && kill $(expr $emupid + "1")
That's the way I would do... this is just an idea...
I tested this ... worked to kill one additional process with name "scummvm" but I'm not sure if this will always work! -
@barrymossel Can you please test this script here: https://ghostbin.com/paste/a29wx
edit: I mean, test with ScummVM. ;-)
-
@meleu said in Mausberry Shutdown Script Doesn't Save Metadata:
@barrymossel Can you please test this script here: https://ghostbin.com/paste/a29wx
edit: I mean, test with ScummVM. ;-)
Nope, didn't exit to ES and did not save lastplayed from game I started before.
-
@barrymossel I knew I made promise do not interact with this code by maybe you can try this one
1.57b - it's just a dirty workaround!Feel free to test!
@meleu
I don't getting it why it does not work.
In generell I would try to detect PPID and then useps
command to find all PIDs stared by PPID. -
@cyperghost I think
pgrep scummvm
(without-f
) would be more effective thant that. -
@cyperghost said in Mausberry Shutdown Script Doesn't Save Metadata:
@barrymossel I knew I made promise do not interact with this code by maybe you can try this one 1.57b - it's just a dirty workaround!
Feel free to test!
I just started a massive scrape, so I won't turn the RPi off now. Depending on when the scrape ends I will try it later or tomorrow evening.
-
@meleu said in Mausberry Shutdown Script Doesn't Save Metadata:
@cyperghost I think
pgrep scummvm
(without-f
) would be more effective thant that.OUTDATED !!
Yes... but I'm finished with that code. But I think usingps
as entry to extract PPID should work. So this is a sniplet coded yesterday with annother intention....
Thank you :)What does happen if you use
killall
command instead ofkill -9
or use killall in general?as meleu alread said pgrep would be the smarter approach!
I just want to create failsafe methods but they aren't effective in CPU load :)so you have to change code line
[[ "$(pgrep scummvm)" ]] && pkill scummvm
or if you are just a killer without p
[[ "$(pgrep scummvm)" ]] && kill "$(pgrep scummvm)"
Sorry for being inconvinient
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.