core: gracefully kill process tree on exit#8947
Conversation
056b682 to
c696e8f
Compare
|
I still need to figure out why the test is failing on GH Actions... |
|
I can confirm that this works in RHEL in an unpackaged electron app, and is able to kill previously recalcitrant processes (a trace server launched from this extension). However, in a packaged Electron app, the process configuration looks the same - the backend main process is the group leader for its descendants - but the backend main process and the trace server survive the application exit. |
94b84db to
bbe4a5b
Compare
52ebef0 to
8c1e86e
Compare
8ea7df7 to
b3593a0
Compare
|
How does VS Code handle this? Do they also have such sophisticated logic for terminating the process tree? Can we use the process termination logic as-is from the language client? I'd prefer that tested code over some in-house solution. |
Both the VSCode shell script that's called in the code you linked and the Forgot about the need for everything to be |
8b83d50 to
c4e9d1e
Compare
colin-grant-work
left a comment
There was a problem hiding this comment.
I have tested this code in a Linux environment and confirmed that it successfully kills processes that are left hanging by version 1.14.0.
c4e9d1e to
27658bc
Compare
When killing a given process, its children are supposed to keep running unaffected. Since we never kill our subprocesses ourselves, we often end up leaking orphaned processes. The most notorious is the plugin-host process. When running the browser version, yarn somehow ends up cleaning up for us. But when running Electron, simply killing the backend process is not enough, we need to find a way to kill everything. This commit addresses this issue, with some platform specifities: - On Windows we'll run `taskkill /f /t /pid xxx` in order to destroy the whole tree from the backend pid. - On UNIX we'll prefer starting the backend process as group leader, this way we can kill the whole group at once. But we'll still also follow parent/child relationships in case some processes are spawned in a different group. Signed-off-by: Paul <paul.marechal@ericsson.com>
27658bc to
133b7d8
Compare
What it does
See commit messages.
Fixes #8946
How to test
(Linux and maybe Mac)
htopto see that the plugin-host process is not running anymore.On Windows I don't really know if this is an issue. But if anything, nothing should be broken on Windows.
Review checklist
Reminder for reviewers