Skip to content

Windows: the daemon's emulator and adb server die with it, and their qemu child keeps the logon task running #1759

Closed

Description

@V3RON

On Windows, simlock daemon stop while a lease is held stops the daemon but leaves three processes running:

  • the leased Android emulator,
  • the adb server,
  • the logon task's headless conhost.exe.

Seen on Windows 11 23H2 (DesktopWindows) while checking #1691's completion conditions for #1698 (PR #1721), with the daemon started from the logon task. Not checked with a daemon started from a shell, or on macOS or Linux.

Expected

simlock daemon stop ends the leases it holds: their emulators stop, and nothing the daemon or its task started is left running.

Possibly related: #1700 (stop and the warm pool's emulator).

Part of #1068.

Written by an agent.

Activity

  1. added
    bug:new
    os:windows
    platform:android
    on Nov 19, 2026
  2. self-assigned this
    on Nov 19, 2026
  3. V3RON commented on Nov 19, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Defect, but not the one Expected asks for. A leased emulator and Simlock's adb server are meant to outlive daemon stop (ADR 0004, ADR 0019, the Android driver manual). On Windows the daemon's own children die with it instead, and their children live on and keep the task's console open.

    src/ports/child-window.test.ts, "a child NodeProcessRunner.spawn logs to a file outlives the daemon on every platform › is started detached on win32" (darwin and linux pass):

    pnpm exec vitest run --project unit src/ports/child-window.test.ts
    - ObjectContaining { "detached": true }
    + { "detached": false, "stdio": ["ignore", 13, 13], "windowsHide": true, ... }
    Tests  1 failed | 7 passed (8)
    

    On DesktopWindows, Node under conhost --headless spawns cmd /c ping, then exits:

    attached: node gone  cmd alive=False  ping alive=True  conhost alive=True
    attached: ping killed                                  conhost alive=False
    detached: node gone  cmd alive=True   ping alive=True  conhost alive=False
    

    Root cause

    src/ports/node-process-runner.ts:121 sets detached: process.platform !== "win32". On Windows, Node kills a non-detached child when Node exits, but not that child's children, and a child writing to a file shares Node's console. So the daemon's exit kills emulator.exe and adb nodaemon server; qemu (and likely an adb fork-server) keep running and hold the task's conhost.exe open. That breaks ADR 0086 §3 (a clean exit ends the task), and IgnoreNew then ignores the next start through the service. !== "win32" was added for POSIX process groups, not survival.

    Simplest fix

    detached: process.platform !== "win32" || typeof options.stdio === "object",

    Only the emulator, the adb server and the supervisor's daemon log to a file. The test pins this shape.

    pnpm exec vitest run --project unit src/ports/child-window.test.ts …  → 4 files passed
    pnpm test:changed  → 481 files, 7198 tests passed
    

    Alternatives rejected

    • Make daemon stop end leases, as the issue expects: goes against ADR 0004 and 0019.
    • An outlivesCaller option on the two driver spawns: more lines, same effect.
    • Detach every Windows spawn: sdkmanager's java could open a visible window.

    Risk

    • A detached emulator has no console: check qemu opens no visible window.
    • Unchecked on Windows: the next daemon adopting the emulator and adb server.
    • The supervisor's daemon is detached too: killing the supervisor leaves it running.

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: no — the issue's expected fix (stop ends leases) changes ADR 0004/0019

    Written by an agent.

  4. removed their assignment
    on Nov 19, 2026
  5. V3RON commented on Nov 19, 2026

    @V3RON
    ContributorAuthor

    Maintainer side (2026-11-19): the triage report is accepted. The Expected section above was wrong. Under ADR 0004 and ADR 0019, leased emulators and Simlock's adb server keep running after daemon stop.

    The real defect: on Windows the daemon's children are not detached (src/ports/node-process-runner.ts:121). When the daemon exits, Windows ends emulator.exe and the adb server, while their children (qemu) live on and hold the logon task's conhost.exe. That breaks ADR 0086 §3, and IgnoreNew then ignores the next start.

    Expected (replaces the one above)

    • After simlock daemon stop on Windows, a held lease's emulator and Simlock's adb server keep running, as on macOS, and the next daemon takes them over.
    • The logon task ends when the daemon exits cleanly, so the next start through the task works.
    • No detached child opens a visible window, and ending the supervisor still ends its daemon.

    Fix shape: the report's one-line detach for children whose output goes to a file, checked on DesktopWindows for the three points above.

    Written by an agent.

  6. added
    bug:ready
    and removed
    bug:new
    on Nov 19, 2026
  7. changed the title [-]Windows: daemon stop with a lease held leaves the emulator, the adb server and the task's console running[/-] [+]Windows: the daemon's emulator and adb server die with it, and their qemu child keeps the logon task running[/+] on Nov 19, 2026
  8. self-assigned this
    on Nov 19, 2026
  9. V3RON commented on Nov 19, 2026

    @V3RON
    ContributorAuthor

    Decision

    A detached emulator on Windows has no console, so its qemu child opens its own console, which shows as a visible Windows Terminal window titled with the qemu path (seen on DesktopWindows at 2b2d0b8).

    Decided: on Windows, a child that outlives the daemon (outlivesCaller: the emulator and Simlock's adb server) starts detached inside conhost.exe --headless, as the logon task already starts the daemon (ADR 0086). Its qemu then inherits a headless console and opens no window. Stopping such a child still ends its whole process tree. (decided in delivery, pending the maintainer)

    Tests: on Windows, a detached outlivesCaller child is spawned through conhost.exe --headless; killing it ends emulator.exe and its qemu. DesktopWindows check: after daemon stop with a held lease, no visible top-level window belongs to the emulator's process tree.

    Written by an agent.

  10. V3RON commented on Nov 19, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1766 (#1759)
    Parked: none
    Waiting: none
    Decided: #1759 — how a detached emulator on Windows gets a console without a visible window → start the emulator and Simlock's adb server inside conhost.exe --headless, as the logon task does (pending the maintainer)

    Written by an agent.

  11. added a commit that references this issue on Nov 19, 2026
    e767520
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:readyos:windowsplatform:android

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions