microsoft / microsoft/WSL

Redirecting WSL2 output to WSL1 hangs

Open
#12,886 8 comments 0 reactions 0 assignees View on GitHub
wsl1
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

### Windows Version

Microsoft Windows [Version 10.0.26100.3775]

### WSL Version

2.4.13.0

### Are you using WSL 1 or WSL 2?

- [x] WSL 2
- [x] WSL 1

### Kernel Version

5.15.167.4

### Distro Version

Alpine 2.21

### Other Software

_No response_

### Repro Steps

I performed these steps with Alpine, but they also work with Ubuntu(WSL1) and Debian(WSL2) from MS Store.

* Open WSL1 terminal
* `/mnt/c/Windows/System32/wsl.exe -d Alpine2 ls | cat` - note that pretty much anything works here. The only requirements are that the distro uses WSL2 and the output is redirected somewhere in WSL1. Redirect to file also works.

### Expected Behavior

The process displays the output of `ls` in the `Alpine2` distro and exits

### Actual Behavior

The process displays the output of `ls` in the `Alpine2` distro and then hangs forever.

Running `ps aux` in the `Alpine2` distro produces the following:
```
~# ps aux
PID USER TIME COMMAND
1 root 0:00 {init(Alpine2)} /init
4 root 0:00 {init} plan9 --control-socket 6 --log-level 4 --server-fd 7 --pipe-fd 9 --log-truncate
7 root 0:00 {SessionLeader} /init
8 root 0:00 {Relay(9)} /init
9 root 0:00 -sh
17 root 0:00 {SessionLeader} /init
18 root 0:00 {Relay(19)} /init
29 root 0:00 ps aux
```
Note the hanging {Relay(19)} process despite PID 19 being over.
Terminating the WSL1 process also ends the hanging `/init` processes in te target WSL2 distro.

### Diagnostic Logs

[WslLogs-2025-05-10_10-47-20.zip](https://github.com/user-attachments/files/20138146/WslLogs-2025-05-10_10-47-20.zip)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the hang with `/mnt/c/Windows/System32/wsl.exe -d Alpine2 ls | cat` from a WSL1 terminal, then inspect the WSL diagnostic logs linked in the issue. Use `ps aux` in the target WSL2 distro to compare the hanging Relay process, and consider the issue done when redirected output exits without leaving WSL2 `/init` processes running.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.