wsl.exe discards the calling Windows process's stdin even when the guest command never reads it
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- cpp
- Domain
- cli, operating-systems
Research direction
The report provides a cmd.exe reproduction showing that wsl.exe -- true consumes piped stdin, while --help and --status do not; it names no source files or tests. Start by finding the Windows-side code that launches guest commands and forwards stdin, then trace how that path differs for help and status. Done means the behavior is corrected or made controllable as the issue discussion decides, with the repro cases checking the result.
Written by the indexing model from the issue text.
Description
Windows Version
Microsoft Windows [Version 10.0.29695.1001]
WSL Version
3.0.3.0 (WSLg 1.0.79, MSRDC 1.2.7391). First seen on 2.7.14.0 and reproduced
unchanged on 3.0.3.0 after wsl --update.
Are you using WSL 1, WSL 2, or WSLC?
- WSL 1
- WSL 2
- WSLC
Kernel Version
6.18.54.1-1
Distro Version
Ubuntu 26.04.1 LTS
Other Software
None. The repro below is cmd.exe only.
Repro Steps
@echo off
echo [1] control, no wsl -- expect "hello"
echo hello | cmd /c "cmd /c exit & findstr ."
echo [2] wsl.exe -- true -- expect "hello"
echo hello | cmd /c "wsl.exe -- true & findstr ."
echo [3] wsl.exe --help, never enters the guest
echo hello | cmd /c "wsl.exe --help > nul 2>&1 & findstr ."
echo [4] workaround, stdin redirected from NUL
echo hello | cmd /c "wsl.exe -- true < NUL & findstr ."
true is used deliberately: the guest command exits immediately and never reads
a byte of stdin.
Expected Behavior
All four print hello. wsl.exe -- true does not read stdin on behalf of a
guest command that does not read stdin, so the bytes are still there for the
next command in the pipeline.
Actual Behavior
[1] control, no wsl -- expect "hello"
hello
[2] wsl.exe -- true -- expect "hello"
<-- empty: the bytes are gone
[3] wsl.exe --help, never enters the guest
hello
[4] workaround, stdin redirected from NUL
hello
Case [3] is the interesting one: invocations that never enter the guest
(--help, --status) leave stdin alone, so the drain is tied to launching a
guest command rather than to running wsl.exe as such.
How much is lost depends on what happens to be buffered at that moment. A small
write followed by EOF disappears completely; a 1 MB stream still being written
survives, because wsl.exe only takes what is available. That is what makes
this so hard to attribute in practice -- it looks intermittent and
data-dependent.
Why this is not simply #11439
#11439 (and
#10429 before it) covered the
Linux to Windows direction -- running cmd.exe from inside a WSL shell eats
the Linux-side stdin -- and was closed as by design, with the rationale that WSL
pipes stdin to the Windows side and cannot know whether the Windows command
consumes it.
This report is the Windows to Linux direction: wsl.exe on the Windows side
discarding the stdin of the Windows process that invoked it. I am raising it
separately because the trade-off looks different here:
wsl.exeis a Windows CLI, so unlike the interop case there is an obvious
place to put an opt-out. There is currently no flag to suppress stdin
forwarding (-nis taken by--no-launchfor--install).sshhas had
-nfor exactly this reason.wslc, the container CLI shipped in this same 3.0.3.0 package, already models
it the other way round:wslc execandwslc createtake
-i, --interactive-- "Attach to stdin and keep it open" -- so stdin is
attached only when asked for.wsl.exeforwards it unconditionally and
offers no way to decline.- The behaviour is not documented in
wsl --helpor in the CLI docs, and it
destroys data with no diagnostic. --helpand--statusnot draining shows the relay is already conditional,
so the condition could plausibly be refined.
If the relay itself must stay as it is, a documented --no-stdin flag (or a
note in the docs and --help) would be enough to make this diagnosable.
How this was found, as an illustration of the cost
wsl.exe was called once in a PowerShell profile, to probe for a config file:
if ((gcm -ea ignore wsl) -and (wsl -- ls '~/.tmux-pwsh.conf' 2>$null)) {
That profile also serves as the DefaultShell for Win32-OpenSSH. PowerShell
loads profiles even for non-interactive -c sessions
(PowerShell/PowerShell#24411),
so every scp and sftp connection to the machine ran that line first, which
swallowed the client's protocol greeting -- scp and sftp then hung forever
with no error on either end. Two days went into blaming PowerShell, Win32-OpenSSH
and MSIX packaging before the profile line turned out to be responsible. The fix
on my side is to hand wsl.exe an empty pipe:
$null | wsl -- ls '~/.tmux-pwsh.conf' 2>$null
Noting it here only because a silent, buffer-dependent loss of stdin is
unusually expensive to track down, which seems worth weighing against the
"cannot know whether it is consumed" argument.
Diagnostic Logs
WslLogs-2026-10-28_12-42-29.tar.gz, collected with
diagnostics/collect-wsl-logs.ps1 while the repro above ran, is attached in a
comment below. (The collector's "press any key" wait was replaced by a call to
the repro script so it could run unattended; that is the only change to it, and
the trace therefore covers exactly the four cases.)
- Dominant language
- C++
- Stars
- 34.4k
- Forks
- 1.9k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 166
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/WSL
-
feature wsl2
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
microsoft/WSL#42306 · 3 comments ·
Maintainers usually reply within 1 day
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
microsoft/WSL#42114 · 3 comments ·
Maintainers usually reply within 1 day
-
feature kernel wsl2
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/WSL#41107 · 3 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
feature kernel
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microsoft/WSL#41054 · 9 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
feature GPU
Difficulty 1/5 1-3 hours Newbie friendliness 70/100
microsoft/WSL#13592 · 4 comments ·
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
nextcloud/passman-android#214 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
2026.11.0 fails to install on Intel macOS: requirements.txt pins cryptography==50.0.2 for Darwin x86_64May be free again A pull request for this issue was closed without being merged. Open
Difficulty 1/5 Under an hour Newbie friendliness 87/100
esphome/esphome#22892 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
distante/esphome-components#50 · 1 comment ·
Maintainers usually reply within 1 day
-
arch-based hyprland
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
noctalia-dev/noctalia#5423 ·
Maintainers usually reply within 1 day