From 68b09c1ed13ee39190d3ca7b11905a7e7118bd41 Mon Sep 17 00:00:00 2001 From: The412Banner Date: Tue, 22 Sep 2026 11:22:31 -0400 Subject: [PATCH] The session's number is claimed when it is registered, not when its process starts The replaced desktop's proot exits on SIGTERM within a tenth of a second - before the new session's start thread had numbered itself - so its exit still matched the current number and ended the new session (4 s on the ended card, then the main menu, with the client audible in the background). The number is taken in onStartCommand now, ahead of any thread. --- .../com/steamdeck/launcher/session/SessionService.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/steamdeck/launcher/session/SessionService.kt b/app/src/main/java/com/steamdeck/launcher/session/SessionService.kt index 42e4ff12e3..4579be15fa 100644 --- a/app/src/main/java/com/steamdeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/steamdeck/launcher/session/SessionService.kt @@ -76,13 +76,17 @@ class SessionService : Service() { if (SessionState.mode == MODE_STEAM) RivalClients.stopBeforeSession(this) SessionState.running = true SessionState.firstFrameSeen = false + // This session's number, claimed here and not when its process starts: the session it + // replaces can report its own exit in the gap between the two, and that exit must not + // be taken as this one's. + val gen = ++sessionGen acquireLocks() Thread({ // A tree the last session left behind (the app was killed or crashed, so its teardown // never ran) would hold the rootfs, the GPU and Steam's lock: nothing of ours should // be alive between sessions outside this process. OrphanReaper.reap("session starting") - runSession() + runSession(gen) }, "session-start").start() // The activity or the notification stops us; the system must not resurrect a session whose // guest processes are long gone. @@ -128,7 +132,7 @@ class SessionService : Service() { // ── The session ───────────────────────────────────────────────────────────────────────── - private fun runSession() { + private fun runSession(gen: Int) { try { LinuxRuntime.writeAccounts(this) } catch (e: Exception) { @@ -394,7 +398,6 @@ class SessionService : Service() { // by the teardown a second after the new one has started, and its exit used to arrive // here as "session ended: 137" and end the NEW session. An exit belongs to the session // that started it. - val gen = ++sessionGen sessionPid = ProcessHelper.exec(line, hostEnv.toStringArray(), root, { status -> if (gen != sessionGen) { Log.i(TAG, "an earlier session's process ended ($status); the current one carries on")