Open tigerinus opened 3 years ago
This is an interesting problem. From WSL's perspective there's no way for us to know that this process is not 'important' and so the distro will keep running until it exits.
On this I'd say that it would be easiest to try to solve this from the powerline-daemon side and maybe have it timeout after a while if no shell is connected to it but looking at its documentation I don't see any easy way of doing that right now
I have following logic in ~/.bash_logout
(in case people came here for the same issue):
if [[ $(ls -l /dev/pts | grep $USER | wc -l) = 1 ]]; then
powerline-daemon -k
fi
I agree with you that there is no way to know which process is important or not. That's why I propose this feature as an option for people to opt-in.
For me, WSL2 is more of a command-line experience for coding, rather than a Linux environment for running complicated background processes. Killing everything after I exited the last prompt is perfectly fine. This option would serve users like me.
Is your feature request related to a problem? Please describe.
I use powerline to customize the shell prompt (it has TMUX integration where others don't).
The tool always have a
powerline-daemon
process running at the background.This prevents WSL2 from reclaiming the memory even when I exit all the shell prompts.
Describe the solution you'd like
It'd be nice to add an option, such that when there is no active pts session, i.e. shell session, regardless how many headless (i.e. pty-less) processes, WSL2 will proceed and reclaim the memory.
Describe alternatives you've considered
I've tried including a script in
.bash_logout
such that when this is the last PTY session, callpowerline-daemon -k
to kill the background process, so later WSL2 will be able to reclaim.Obviously, this works for this specific process only.