godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.47k stars 148 forks source link

Fix debugged process not being terminated when debugging session closes on Linux #620

Closed vpyatnitskiy closed 2 months ago

vpyatnitskiy commented 3 months ago

This is a follow-up for https://github.com/godotengine/godot-vscode-plugin/pull/613. Both PRs need to be merged for this change to work.

Issue:

On Linux, when debugging session is initiated and then closed from VS Code, the game (i.e. the process being debugged) does not terminate.

Steps to reproduce are as you would expect:

  1. Have a launch configuration for GDScript in VS Code properly set up.

  2. Launch a project with F5.

  3. Switch back to VS Code. Press Shift+F5 to close the debugging session.

  4. The session closes but the project continues running.

Cause:

Solution:

Add detached: true to force both processes to share a process group. Rely on the change from https://github.com/godotengine/godot-vscode-plugin/pull/613 to kill the entire group rather than individual process(es).

Other notes:

Unlike https://github.com/godotengine/godot-vscode-plugin/pull/613, this change is not restricted to Linux, and may potentially cause unintended consequences on Windows and/or Mac OS. This shouldn't be the case assuming headless LSP works properly on these platforms, but more extensive testing is necessary.

In case it does cause problems on other platforms, the suggested fix is to set the flag depending on the platform, e.g. detached: process.platform !== "win32" && process.platform !== "darwin" or similar.

Additionally, Godot 3 integration may need to be tested separately since it uses a separate code path.

enekonieto commented 3 months ago

This solves the issue using Linux and Godot 3.5.3

DaelonSuzuka commented 2 months ago

@vpyatnitskiy Thanks for doing the legwork on this.

DaelonSuzuka commented 2 months ago

I quickly tested master after merging and it looks like killing the child works correctly on Windows using both 3.5 and 4.2.