简体   繁体   English

关闭远程 WSL 连接后如何防止打开新的空 VSCode 实例

[英]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:您可以通过以下方式进一步证明这一点:

  1. Opening a WSL shell outside of VSCode在 VSCode 之外打开 WSL shell
  2. Running ps auxw运行ps auxw
  3. Opening VSCode with a WSL remote connection使用 WSL 远程连接打开 VSCode
  4. Running ps aux in the original shell again (notice the VSCode processes)再次在原来的 shell 中运行ps aux (注意 VSCode 进程)
  5. Close VSCode关闭 VSCode
  6. Running 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.

相关问题 每次保存后如何防止VSCode打开输出面板? - How to prevent VSCode opening output panel after each save? 如何防止 VSCode 在启动时打开所有 git 存储库? - How to prevent VSCode from opening all git repositories at startup? VSCode:如何通过 ssh 远程连接到远程 WSL2 - VSCode: how to ssh remote connect to remote WSL2 如何防止VSCode多次打开同一文件? - How to prevent VSCode from opening same file multiple times? 通过远程 WSL 扩展在 vscode 中使用 WSL bash 与在 Windows 中通过选择作为默认 shell 使用它有何不同? - How is using WSL bash in vscode through the remote WSL extension different from using it by selecting as default shell while in windows? 引入远程WSL功能后,vscode无法正常工作 - vscode is not working properly after introduction of remote WSL feature vscode-remote-release 和 wsl 2 - vscode-remote-release and wsl 2 如何从远程 VSCode 实例隧道/代理/转发流量 - How to tunnel/proxy/forward traffic from remote VSCode instance 如何通过右键单击打开VSCode Remote-WSL - How to open VSCode Remote-WSL by right click VSCode:防止文件在新选项卡中打开,而是将注意力集中在另一个窗格中已打开的选项卡上 - VSCode: Prevent file from opening in a new tab and instead focus to already opened tab in another pane
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM