The WSL instance still shuts down automatically when all WSL terminals are closed, after waiting for a while.
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
### Windows Version
Microsoft Windows [版本 10.0.22621.1555]
### WSL Version
WSL 版本: 1.2.0.0
内核版本: 5.15.90.1
WSLg 版本: 1.0.51
MSRDC 版本: 1.2.3770
Direct3D 版本: 1.608.2-61064218
DXCore 版本: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows 版本: 10.0.22621.1555
### Are you using WSL 1 or WSL 2?
- [X] WSL 2
- [ ] WSL 1
### Kernel Version
默认分发: rocky9 默认版本: 2
### Distro Version
_No response_
### Other Software
```bash
docker --version
# Docker version 20.10.21, build baeda1f
````
### Repro Steps
1. Execute "wsl" in cmd to launch wsl.
2. Press Ctrl + D to exit the terminal of the wsl instance.
3. Wait for a while and then execute "wsl -l -v". Check if the wsl status is "Stopped".
I have already configured to prevent automatic shutdown, the configuration is as follows:
.wslconfig
```text
# Settings apply across all Linux distros running on WSL 2
[wsl2]
# Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
memory=4GB
# Sets the VM to use two virtual processors
processors=6
# Specify a custom Linux kernel to use with your installed distros. The default kernel used can be found at https://github.com/microsoft/WSL2-Linux-Kernel
# kernel=C:\\temp\\myCustomKernel
# Sets additional kernel parameters, in this case enabling older Linux base images such as Centos 6
kernelCommandLine = vsyscall=emulate
# Sets amount of swap storage space to 8GB, default is 25% of available RAM
swap=1GB
safeMode=false
# Disable page reporting so WSL retains all allocated memory claimed from Windows and releases none back when free
pageReporting=true
# Turn off default connection to bind WSL 2 localhost to Windows localhost
localhostforwarding=true
guiApplications=true
# Disables nested virtualization
nestedVirtualization=true
# Turns on output console showing contents of dmesg when opening a WSL 2 distro for debugging
debugConsole=true
vmIdleTimeout=604800000
```
[root@DESKTOP-2U5HSUB ~]# cat /etc/wsl.conf
```text
[wsl]
autostop=false
[boot]
systemd = true
# Set a command to run when a new WSL instance launches. This example starts the Docker container service.
command = ls -al
# Automatically mount Windows drive when the distribution is launched
[automount]
# Set to true will automount fixed drives (C:/ or D:/) with DrvFs under the root directory set above. Set to false means drives won't be mounted automatically, but need to be mounted manually or with fstab.
enabled = true
# Sets the directory where fixed drives will be automatically mounted. This example changes the mount location, so your C-drive would be /c, rather than the default /mnt/c.
# root = /
# DrvFs-specific options can be specified.
#options = "metadata,uid=0,gid=0,umask=022,fmask=11"
mountFsTab = true
# Network host settings that enable the DNS server used by WSL 2. This example changes the hostname, sets generateHosts to false, preventing WSL from the default behavior of auto-generating /etc/hosts, and sets generateResolvConf to false, preventing WSL from auto-generating /etc/resolv.conf, so that you can create your own (ie. nameserver 1.1.1.1).
[network]
# hostname = DemoHost
generateHosts = true
generateResolvConf = true
# Set whether WSL supports interop process like launching Windows apps and adding path variables. Setting these to false will block the launch of Windows processes and block adding $PATH environment variables.
[interop]
enabled = true
appendWindowsPath = true
# Set the user when launching a distribution with WSL.
[user]
default = root
```
### Expected Behavior
The WSL instance keeps running even after closing all terminals.
### Actual Behavior
The WSL instance automatically shuts down after waiting for a while after closing all terminals.
### Diagnostic Logs
DebugConsole logs the following when WSL is closed.
```text
[ 146.602703] Exception:
[ 146.602709] Operation canceled @p9io.cpp:258 (AcceptAsync)
[ 146.604567]
?????????????
```
Contributor 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.
Research direction
Reproduce the shutdown using the wsl entry point, then check the state with `wsl -l -v` after closing the terminal. Compare the reported `.wslconfig` and `/etc/wsl.conf` settings with the DebugConsole output, including the `AcceptAsync` cancellation; done means the WSL instance remains running after all terminals close.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100