-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean-up child processes on dispose #918
Clean-up child processes on dispose #918
Conversation
I test this with Linux and macOS, and it works as expected. When I test it on a Windows virtual machine, the help server cannot be properly started. @ManuelHentschel Would you like to take a look on Windows? |
Now the help server could start on Windows but it never exits. When I quit vscode, those child processes do not exit, including the language server and its background workers. Looks like all the spawned processes do not automatically exit even when vscode exits. This does not happen on Linux and macOS. |
Is it possible that the For reference: |
Looks like specifying |
What if we make all processes disposable via |
Currently, we already push help server to the subscriptions where |
We might need to keep track of all long-running child processes we create (e.g. help server, language server). |
It looks like the following works:
We need to apply these to help server and language server so that all processes are cleaned up properly when vscode exits. |
Sorry, I was little busy last week. I'll take closer look this weekend and try to come up with something! |
With the latest commit here, it should work on Windows, Linux and macOS now. I tested with all three platforms and you might want to confirm. |
Sorry that was a mistake fixed via 31db66a. Should be working now. |
Through some testing, the latest commit should work with Windows and macOS but not Linux. Let me take another look on the Linux case where |
On Linux, |
Through some testing, the latest commit works with Windows, Linux and macOS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested on windows 10 and ubuntu inside wsl, both worked fine. Thanks!
@renkun-ken I don't know if this is the same issue, but per my read, this is still broken on Windows 10 as of 2.3.5: Over the course of the day working on several projects, this becomes quite unwieldy. Do I need to open a separate issue? |
@beansrowning Are they new processes or old orphan processes from the previous versions? |
I started from a fresh install of VSCode, installed VSCode-R via extensions (version 2.3.5), opened up an R project, and then closed the window and there are the 19 orphaned processes. |
Quote strange. @ManuelHentschel Do you think it might be related to certain Windows setup? For example, which terminal is used? |
Maybe this can be helpful, which use following code to do this including both linux and windows:
the windows command |
Just a workaround, I have implemented some
It seems |
To kill excess R.exe, without a running ancestor process "Code.exe", and their child processes automatically, add following code into our
|
The
|
Thanks renkun-ken for great helping us in processing these problem. As discussed in #936, windows users can try to change your |
What problem did you solve?
Closes #902
Closes #911
It looks like the behavior of child processes created by
cp.spawn()
andcp.exec()
are platform-dependent in terms of whether they could be killed bytree-kill
orcp.kill()
indispose()
.This PR tracks all long-running child processes (e.g. help server, rmarkdown preview, langauge server) and explictly kill them on dispose so that it is unlikely to leave orphan processes when vscode exits.
Note that the way to kill process is platform-dependent. This PR uses
cp.exec()
in Windows andcp.spawn
otherwise to start child process and usestree-kill
on Windows andcp.kill()
on other platforms. It is the only way I find working on Windows, Linux, and macOS.(If you do not have screenshot) How can I check this pull request?
watch -d 'ps aux | grep /exec/R'
to monitor R processesThe help server, language server, and rmarkdown preview processes should be properly killed on reload or exit.