From 49ac2f82d1582d15d3cf82a52a4e4229ff274469 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 16 Nov 2026 06:54:03 +0100 Subject: [PATCH] fix(wsl): start the distro holder without a visible console window (#41126) The WSL distro holder was spawned with DETACHED_PROCESS, so it had no console. System32's wsl.exe then starts the WSL package's wsl.exe, a console program, and Windows gave it a new visible console: an empty terminal window on every Orca start with a saved WSL host, which also killed the holder when closed. Use CREATE_NO_WINDOW in place of DETACHED_PROCESS so the holder owns a hidden console that its children inherit. The flags cannot be combined (Windows ignores CREATE_NO_WINDOW with DETACHED_PROCESS). The new process group, job breakaway retry and NUL-only handle list are unchanged. Fixes #41125 Co-authored-by: Neil --- native/windows-security/src/isolated-spawn.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/native/windows-security/src/isolated-spawn.cc b/native/windows-security/src/isolated-spawn.cc index 5ac5496c173..1eac6203255 100644 --- a/native/windows-security/src/isolated-spawn.cc +++ b/native/windows-security/src/isolated-spawn.cc @@ -1,6 +1,9 @@ // libuv spawns with bInheritHandles=TRUE and no handle list, so every inheritable handle in Orca // reaches a long-lived child. This spawn lists exactly one NUL handle, used for all three stdio. -// Flags mirror libuv's detached spawn plus CREATE_BREAKAWAY_FROM_JOB: a holder must outlive a +// Flags follow libuv's detached spawn, with CREATE_NO_WINDOW in place of DETACHED_PROCESS: a +// console-less holder makes Windows open a new, visible console for every console program it starts +// (System32's wsl.exe starts the WSL package's wsl.exe, which shows as an empty terminal window), +// while a windowless console is inherited. CREATE_BREAKAWAY_FROM_JOB: a holder must outlive a // kill-on-close job Orca was launched into (an OpenSSH session's, a terminal's). A job that forbids // breakaway fails that with ERROR_ACCESS_DENIED; the spawn then retries inside it and reports so. @@ -93,7 +96,7 @@ Napi::Value SpawnDetachedIsolated(const Napi::CallbackInfo& info) { startup.StartupInfo.hStdError = nul; startup.lpAttributeList = attributes; PROCESS_INFORMATION created{}; - const DWORD flags = CREATE_UNICODE_ENVIRONMENT | DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP | + const DWORD flags = CREATE_UNICODE_ENVIRONMENT | CREATE_NO_WINDOW | CREATE_NEW_PROCESS_GROUP | EXTENDED_STARTUPINFO_PRESENT; DWORD error = ERROR_SUCCESS; auto create = [&](DWORD extra) {