/** * @file * * Pure helpers for finding the Android emulator process that **outlives the pid * the harness killed**. * * Under `-no-window` the emulator's backend process is * `qemu-system-x86_64-headless` (`qemu-system-x86_64` when windowed), not the * `emulator` launcher the harness spawned and holds a `ChildProcess` for. The * launcher exits or is killed, and the backend is what actually holds the AVD's * `multiinstance.lock` and the console/adb ports — so `taskkill /F /T` against * the launcher's pid reports success while the emulator keeps running. Every * later run against that AVD then dies with `Running multiple emulators with the * same AVD is an experimental feature`, which never reaches the user because the * emulator writes it to its own stdout. * * Note that the obvious filter — `-Name qemu-system-x86_64` / matching that * exact image name — does **not** match the `-headless` build, which is how the * leftover stays invisible through several rounds of "no emulator is running". * * Ownership is decided by a **pre-launch snapshot**: a backend already running * before this run started its own belongs to somebody else (another AVD, or one * the user booted by hand) and is never touched. Kept separate from the * integration-only `transport-factory` so the parsing and the selection stay * unit-testable. */ /** * One process from a host process listing. */ export interface ProcessListEntry { /** The process/image name, as the platform's listing reports it. */ readonly name: string; /** The process ID. */ readonly pid: number; } /** * Parameters for {@link selectEmulatorBackendPids}. */ export interface SelectEmulatorBackendPidsParams { /** Emulator backend PIDs seen **before** this run launched its emulator, which it therefore does not own. */ readonly knownPids: readonly number[]; /** The host's current process listing. */ readonly processes: readonly ProcessListEntry[]; } /** * Parses `ps -eo pid=,comm=` output. * * @param processListOutput - Raw stdout of the `ps` listing. * @returns One entry per parsable row, in listed order. */ export declare function parsePosixProcessList(processListOutput: string): ProcessListEntry[]; /** * Parses `tasklist /FO CSV /NH` output. * * Only the first two fields are read — the image name and the PID — so the * memory column's own commas cannot confuse the split. * * @param taskListOutput - Raw stdout of the `tasklist` listing. * @returns One entry per parsable row, in listed order. */ export declare function parseWindowsTaskList(taskListOutput: string): ProcessListEntry[]; /** * Selects the emulator processes this run is responsible for killing. * * @param params - The current listing plus the PIDs that predate this run's emulator. * @returns The PIDs of emulator processes this run owns, in listed order. */ export declare function selectEmulatorBackendPids(params: SelectEmulatorBackendPidsParams): number[];