about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-07-04 17:55:20 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-07-04 17:55:20 +0300
commit7f113fba7226a3da8ca0972224750628d29d64ae (patch)
tree48922cb988a4f78054b5c931835aa991698fb710
parent31815ae3294cc24d3cd435403e49004acf037804 (diff)
downloadfungus-launcher-7f113fba7226a3da8ca0972224750628d29d64ae.tar.gz
fungus-launcher-7f113fba7226a3da8ca0972224750628d29d64ae.tar.xz
fix fungus-run not exiting properly on spawned umu process exit because it did wait() too soon
-rw-r--r--fungus/run_manager.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/fungus/run_manager.py b/fungus/run_manager.py
index cbb1026..b0e6275 100644
--- a/fungus/run_manager.py
+++ b/fungus/run_manager.py
@@ -7,7 +7,6 @@ All Gtk/Glib/D-Bus coupling lives here.  For pure business logic, see
 
 from __future__ import annotations
 
-import os
 import sys
 from threading import Thread
 
@@ -198,6 +197,15 @@ def handle_command(
             make_io_handler(True),
         )
 
+        def _on_child_exit(pid: int, condition: int) -> bool:
+            """GLib child watch callback — fires when the bwrap process exits.
+
+            Calls launcher.cleanup() to stop the watchdog, save playtime,
+            close the splash window, and quit GTK.
+            """
+            launcher.cleanup()
+            return False
+
         GLib.child_watch_add(
             GLib.PRIORITY_DEFAULT,
             handle.pid,
@@ -205,10 +213,12 @@ def handle_command(
         )
 
     # ── Start process in a thread and enter the event loop ─────────
+    # The child watch handles process lifecycle entirely.  The thread
+    # is kept as a no-op placeholder; it must NOT call wait() because
+    # that would reap the child and prevent GLib's child watch from
+    # firing (glib docs: waitid ECHILD when child already reaped).
     def run_process():
-        # Wait for the process to exit (the watchdog handles orphans)
-        if handle.process:
-            handle.process.wait()
+        pass
 
     process_thread = Thread(target=run_process, daemon=True)
     process_thread.start()
@@ -219,19 +229,6 @@ def handle_command(
     sys.exit(0)
 
 
-def _on_child_exit(pid: int, condition: int) -> bool:
-    """GLib child watch callback — fires when the bwrap process exits."""
-    if os.WIFEXITED(condition):
-        exit_code = os.WEXITSTATUS(condition)
-        if exit_code != 0:
-            # The error is handled by the splash window's show_error
-            # which is triggered via the on_process_exit callback
-            pass
-
-    # Cleanup is handled by on_process_exit callback
-    return False
-
-
 # ---------------------------------------------------------------------------
 # Convenience: load a game from the library
 # ---------------------------------------------------------------------------