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 <neil@stably.ai>
This commit is contained in:
Thomas
2026-11-15 21:54:03 -08:00
committed by GitHub
co-authored by Neil
parent f6a212287e
commit 49ac2f82d1
@@ -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) {