Conversation
wait_lock() installed trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT On EXIT the trap ran rm (status 0) and then re-exited with rm's status, so every script that had taken the settings lock exited 0 however it ended. runemu.sh takes it for the cooling profile and netplay mode, so its 'quit 1' after a failed launch reached EmulationStation as 0. And $lockfile is never assigned anywhere, so the trap also never removed the lock it was there to release: a script killed while holding it left /tmp/.system.cfg.lock behind and every later set_setting spun forever. Save $? first and exit with it. Name the lock (J_CONF_LOCK) and remove it only when this shell still owns it: every caller releases the lock itself a few lines after taking it, the trap stays installed for the rest of the shell's life, and by the time a long-lived script such as runemu.sh exits another process may hold the file. The EXIT arm stays for callers under set -e, where a failed sed inside del_setting exits with the lock held. With the status reported for the first time, an emulator ended by the global exit hotkey (killall -9 -> 137, SIGTERM -> 143) would read as a failed launch: EmulationStation records play count, play time and last-played only on 0. runemu.sh maps 137 and 143 to 0 with a log line; every other non-zero status still collapses to 1, leaving 200-300 for the messages EmulationStation can name. Checked on a GENERIC_X64 guest: with a 64 KiB zero ROM runemu.sh logged 'exiting with 1' and returned 0 before, 1 after; exit 7 while holding the lock returns 7 and releases it; a lock another pid owns at exit is left alone; TERM while holding returns 143 and releases it; a live RetroArch ended with SIGKILL returns 0.
Closed
4 tasks
maxengel
added a commit
to maxengel/rocknix
that referenced
this pull request
Sep 8, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
wait_lock()inprofile.d/001-functionsinstallsOn EXIT the trap runs
rm(status 0) and then re-exits with rm's status, so every script that has taken the settings lock exits 0 however it ended.runemu.shtakes it (cooling profile, netplay mode), so itsquit 1after a failed launch reaches EmulationStation as 0 — a RetroArchFailed to load contentlooked like a clean exit.$lockfileis also never assigned anywhere, so the trap never removed the lock it was there to release: a script killed while holding it left/tmp/.system.cfg.lockbehind and laterset_settingcalls spun forever.Fix
$?first and exit with it. Name the lock (J_CONF_LOCK) and remove it only when this shell still owns it: every caller releases the lock itself a few lines after taking it, the trap stays installed for the rest of the shell's life, and by the time a long-lived script likerunemu.shexits another process may hold the file. The EXIT arm stays for callers underset -e, where a failedsedinsidedel_settingexits with the lock held.killall -9→ 137, SIGTERM → 143) would read as a failed launch — EmulationStation records play count and last-played only on 0.runemu.shmaps 137 and 143 to 0 with a log line; every other non-zero status still collapses to 1, leaving 200–300 for the messages EmulationStation can name.Testing
On a GENERIC_X64 build: with a 64 KiB zero ROM,
runemu.shloggedexiting with 1and returned 0 before, 1 after;exit 7while holding the lock returns 7 and releases it; a lock another pid owns at exit is left alone; TERM while holding returns 143 and releases it;set -ewith a failedsedindel_settingreturns 1 and releases the lock (was 0 with the lock left behind); a live RetroArch ended with SIGKILL returns 0. The same failed launch, driven through EmulationStation, reached the post-launch step as exit 1. Also running on two Anbernic H700 handhelds.Known edge, left as is: RetroArch force-quit by the hotkey's SIGTERM exits 1 on its own, indistinguishable from a failed load.
No user-facing option or documentation changes.