I hope you’ve had a refreshing summer vacation!
From your appreciated support before the summer, natively compiled MakeCode Arcade games now run great on the Raspberry Pi with regards to using either the keyboard OR a gamepad as controller input.
However, there’s something not quite right with the execution and exiting of the natively compiled .elf files:
When exiting a natively compiled .elf arcade game, the system freezes with the last displayed screen image of the game, and does not exit gracefully and does not return to the calling process.
The only way to exit without rebooting the Pi, is to ssh into it and kill -9 the parent/calling bash process. The symptoms are the same regardless of whether executing in regular ways as pi or sudo, and with
fork | exec ./anyarcadegame.elf.
One way to avoid the freeze, is to execute the game with
exec ./anyarcadegame.elf. But this is a really bad workaround, since the calling/parent process is here replaced by the game, and on game exit(or rather end of execution) the calling/parent (bash) process is gone, and one has to log in again. When executing like this, the game also exits in the same way when
remaining lives = 0 or if you win the game, in stead of resetting/restarting the game, as it should in these circumstances.
Could you please have a quick look at the exit code/conditions for either the (native) compiler process or the natively rpi compiled elf files? There seems to be something wrong or not fully in compliance with how most other executables handles exit.
Or maybe there are other ways to execute files in Linux/Raspbian that I don’t know of and that might work?
Not sure if this helps, but
ps afx (process tree) from the most recent execution shows:
PID TTY STAT TIME COMMAND
1157 tty1 S 0:00 \_ -bash
1746 tty1 Zl+ 0:05 \ _ [arcade-jumpy-pl]
On attempts to exiting the game with the assigned exit button or through the in-game menu exit option, process 1746 is killed, but 1157 remains with the last displayed game image displayed in a frozen state with the whole system and input peripherals frozen and unresponsive.
With it seems that the game process 1746 already is dead/a zombie process, event though the game is running fine until I attempt to exit, and thus cannot be killed without killing the parent process?
Following the execution of MakeCode arcade games using
top, I observe that the game PID switches status Sl+ (interruptible sleep, foreground process group and multi-threaded) to Zl+ (Zombie, multi-threaded and foreground) only after pushing the A button until the introduction screens are finished and what seems to be when the actual gameplay or maybe the game.onUpdate() function/loop starts…
If I execute
./anyarcadegame.elf via ssh from TTY pts/0, I can play the game locally on tty1, but the shell command prompt and letters from key presses appear in the background of the game framebuffer. However, when exiting the game from tty, nothing hangs on either pts/0 or tty1 except the last displayed image from the game in the framebuffer, and the game process is terminated successfully on pts/0. On tty I’m now able to clear this framebuffer using the
clear command, since neither the system nor keyboard hangs when executing from pts/0, like it always does when executing directly from tty1. -Really stuck here on getting
anyarcadegames.elf files exiting gracefully and returning control to the parent shell process, like for any other executable files on my Pi systems(tested on RPi 3 and 4).