Repository navigation
Description
Version
Microsoft Windows [Version 10.0.21354.1]
WSL Version
- WSL 2
- WSL 1
Kernel Version
5.10.102.1
Distro Version
Ubuntu 20.04 (but can repro with any)
Other Software
No response
Repro Steps
In a fresh Ubuntu 20.04 WSL2 instance:
- Add a
[boot]section withcommand = service cron startto/etc/wsl.conf - Restart WSL (e.g.
wsl --shutdown; wsl ~ -d Ubuntu) - Confirm
crondaemon is running withps axjf - Exit shell/WSL
- Wait 15+ seconds
wsl -l -v
Result: Ubuntu will be in STOPPED state, even though it still had running processes (cron)
- Restart the instance:
wsl ~ -d Ubuntu sudo rm /etc/wsl.conf- Exit shell/WSL
wsl --shutdownwsl -d Ubuntu -u root -e sh -c "service cron start"- Wait 30 seconds, 60 seconds, etc.
wsl -l -v
Result: Ubuntu will (correctly) be in RUNNING state.
Expected Behavior
Starting a background process via boot.command will prevent the instance termination timeout, since it is a process that hasn't exited on its own.
boot.command behavior, at least in regards to process detection and cleanup, should be the same as when started interactively or via wsl --execute.
Actual Behavior
Regardless of the boot.command, the instance is terminated after 15 seconds unless some other process, started interactively (even if backgrounded) is still running.
For instance, with the /etc/wsl.conf in place, you can interactively run nohup sleep 10000 &, exit the WSL instance, and it will continue in the RUNNING state for (presumably) the next 10,000 seconds.
And it's not just cron, of course. Even a command = sleep 10000 will self-terminate after 15 seconds.
I thought this might be due to the lack of a pty for the boot.command, but I haven't been able to reproduce the behavior with something like:
wsl -d Ubuntu -u root -e sh -c "service cron start < /dev/null > /dev/null 2>&1"
That still works -- It never self-terminates.
I honestly thought boot.command worked properly at one point, but I now think I might have been masking the problem since I usually run ssh-agent (via keychain) in my startup config. So there's typically another background process that is preventing the instance from being considered "idle".
Additional notes:
- Reproduced under both Windows 11 GA as well as "Preview" release 0.64.0.
- This is not vmIdleTimeout related (see vmIdleTimeout has no effect #8659)
- This will impact the Example wsl.conf file referenced in the doc. The same problem will happen with
command = service docker start.
Diagnostic Logs
No response
Activity
[-]Instance termination timeout does not detect processes started via boot.command[/-][+]Instance self-terminates prematurely when started with a background process in boot.command[/+]NotTheDr01ds commentedon Oct 18, 2022
I'm closing this, at least for now, because: