[英]How to prevent a new empty VSCode instance from opening after closing a remote WSL connection
I use VSCode with Remote WSL extension.我使用带有远程 WSL扩展的 VSCode。
When I quit remote WSL I use the Close Remote Connection
button/command.当我退出远程 WSL 时,我使用Close Remote Connection
按钮/命令。 VSCode closes the current window, but automatically opens a new empty instance. VSCode 会关闭当前的 window,但会自动打开一个新的空实例。
How to prevent a new empty VSCode instance from opening after closing a remote WSL connection?关闭远程 WSL 连接后如何防止打开新的空 VSCode 实例?
90% of the time when I finish WSL I don't need a new VSCode window.当我完成 WSL 时,90% 的时间都不需要新的 VSCode window。
Note: I can use X
of course, but I'm not sure this is the right way to leave a remote connection注意:我当然可以使用X
,但我不确定这是离开远程连接的正确方法
I can understand your concern around terminating the whole thing ( X
), but I don't think it's a problem here (and is the right way to accomplish what you want).我可以理解您对终止整个事情( X
)的担忧,但我认为这不是问题(并且是实现您想要的正确方法)。 When VSCode exits, the WSL2 subsystem (and instance) is still running in the background.当 VSCode 退出时,WSL2 子系统(和实例)仍在后台运行。
You can demonstrate this by running wsl.exe -l -v
from cmd or PowerShell and seeing that it is still in the Running
state after exiting VSCode.您可以通过从 cmd 或 PowerShell 运行wsl.exe -l -v
来证明这一点,并在退出 VSCode 后看到它仍在Running
state 中。
To truly exit the WSL instance, you would need to run wsl.exe -t <distro>
or, to shut down the entire subsystem, wsl.exe --shutdown
.要真正退出 WSL 实例,您需要运行wsl.exe -t <distro>
或关闭整个子系统wsl.exe --shutdown
。 I'm going to assume that those are "clean" shutdowns, but at any rate, we know that VSCode's termination is "clean" since it really only terminates its own WSL processes when it exits.我将假设这些是“干净”的关闭,但无论如何,我们知道 VSCode 的终止是“干净的”,因为它实际上只在退出时终止自己的 WSL 进程。
You can further demonstrate this by:您可以通过以下方式进一步证明这一点:
ps auxw
运行ps auxw
ps aux
in the original shell again (notice the VSCode processes)再次在原来的 shell 中运行ps aux
(注意 VSCode 进程)ps aux
one final time in the original shell to see that only the VSCode processes have been terminated.在原来的 shell 中最后一次运行ps aux
可以看到只有 VSCode 进程已终止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.