Linux – WSL2 X11 programs “disappear”

windows 10windows-subsystem-for-linuxxorg

I'm mostly very happy with WSL2 on Windows 10, having just switched from Mac. I run X410 on the Windows host and start X11 apps inside WSL by setting

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }'):0.0

before starting my program.

It works fine for a while, but after my computer wakes up from sleep, the X window is gone. The application is still shown as running in ps.

I have a feeling it has to do with losing network connection between the X11 app and the X410 server, but I'm not sure. Has anyone experienced this and come up with a workaround?

I'm on Windows 10 Insider Preview build 18945.

Best Answer

  • You're right it's an issue with the networking. It effects all X11 connections to Hyper-V apparently. A solution is to use something other than TCP/IP for the X11 connection.

    The developer of the Windows X11 server x410 explained how to fix it for Hyper-V VMs by using Virtual Sockets here.

    Unfortunately, he also explains on at the end of this more extensive article he wasn't able to get this working on WSL2. He's going to wait for WSL2 to mature until it has better inter-OS communication via Unix domain sockets.