fix(wsl): restore Windows interop after another distro wipes it (#27682)

* fix(wsl): detect and restore a wiped WSLInterop entry in running distros

On WSL < 3.0.1 a graceful stop of any systemd distro deletes every
binfmt_misc entry VM-wide, so Windows .exe launches (code ., explorer.exe,
the orca WSL CLI bridge) fail with Exec format error in every other distro.

Check, never boot: 5 s after a WSL terminal env build (gated on the distro
being in the confirmed running list, at most once a minute per distro), and
whenever a confirmed running-distro probe shows another distro stopped.
Repair is automatic and idempotent as root, skipped when the distro's
wsl.conf sets [interop] enabled=false, single-flight per distro, with a
10 minute backoff after a failed repair.

* fix(wsl): repair interop with a single register write matching WSL's flags

Busybox printf writes a trailing newline separately; the kernel registers the
entry, then rejects the lone newline, so the repair reported failure after
succeeding. Write without the newline and let the re-check decide. Use WSL's
own P flags rather than PF, and treat an entry restored between probe and
repair as intact. Add a spawn-budget test.
This commit is contained in:
Neil
2026-10-11 19:16:47 -07:00
committed by GitHub
parent a3e97184f4
commit d8ebe75efe
10 changed files with 724 additions and 4 deletions
+8 -2
View File
@@ -17,9 +17,15 @@ export function quotePosixShell(value: string): string {
*/
export function buildWslExecArgs(
distro: string | undefined,
shellArgs: readonly string[]
shellArgs: readonly string[],
options: { user?: string } = {}
): string[] {
return [...(distro ? ['-d', distro] : []), '--exec', ...shellArgs]
return [
...(distro ? ['-d', distro] : []),
...(options.user ? ['-u', options.user] : []),
'--exec',
...shellArgs
]
}
export function buildWslLoginShellCommand(command: string): string {