-
Notifications
You must be signed in to change notification settings - Fork 138
Use taskkill for win32
#941
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
Use taskkill for win32
#941
Conversation
7f7593b to
0a4c75a
Compare
|
Thanks. Installing this artifact and I give a new try. |
|
The same with previous build, |
|
So far I tried two configurations:
I followed the usual workflow: loaded R files, edited R files, executed lines, created a R terminal, loaded R workspace, quit from R terminal, switched from R project (intending with R files) and a Nodejs (intending with no R files) and back, and so on. I don't see leaked processes when I close vscode. So for me it works. @Yunuuuu What are your steps to reproduce the issue? |
|
It seems magic. I rerun a new session with configuration 1 (with "r.rpath.windows" set) and I give you a feedback. |
|
I used |
|
And we changed the setting |
|
Agreed. We have three configurations:
|
|
Again, with configuration 1, after 1 hour of vscode inactivity, while I was in a few video calls, I closed vscode and I opened process explorer (I said myself just in case). Sigh, I noticed those "frontend" processes. Really I have no idea what it is happening. |
|
Looks like in your cases, the The latest commit adds a log file at If the spawned process triggers |
|
Installed. Thanks a lot. Tried with Now I give a try commenting |
|
Ok here the log without any set for |
|
Ok. Next try. I manually killed all the processes (R.exe and Rterm.exe) and started again vscode, played a bit and closed it. Here the log and the process. The processes 10144 and 15424 left behind are not in the log. Interesting. |
|
Another day, other thoughts. ;) Using If |
|
Thanks for the thorough testing! In my testing, the log looks quite weird: The |
|
Here trying to debug the extension, just to understand why log lines, terminating and disposed, are not printed. If an extension needs to dispose a resource, it needs to add the disposing function to the so called extension subscriptions; then, when vscode exit, or the extension is unloaded, those functions are called and the objects are disposed. Basically we have in
Eventually If I set a breakpoint inside the disposing handler (where there are the log lines), for example just after the taskkill line, the execution is halted at the breakpoint. So far it is ok. What I noticed after a few seconds the execution is halted and, maybe, while I had been exploring the values of the variables, suddenly the debugger is stopped and the whole process exits. So I was wondering if there is an high-order logic about disposing lifecycle, limiting the time where the disposing function in the subscription is executed. I tried to give a look at vscode docs, but, weirdly, I didn't find any relevant info about this topic. I say it in the wrong way: like when the callback of a promise is not executed until the end, because the main process is suddenly terminated. Also this would explain the different behaviours for the different users (R.exe vs. Rterm, the printed log lines): it depends how fast the local machines are and it depends on the context of the language server (loaded files and so on). Basically I am afraid the disposing logic is not robust, but I don't see the failure point (in the extension or in vscode). |
|
Thanks for opening the issue in the "upstream". Anyway my next steps are starting from the |
|
Breaking News. The fix is "easy". Use the sync version of spawn for taskkill:
otherwise the dispose function is terminated, when quitting vscode, before the spawned taskkill killed all the subprocesses. Details later. |
3dc9f7e to
8586c1c
Compare
|
Thanks for the fix! I tested it and it works magically 👍 |
|
Perfect! Thanks @renkun-ken for this awesome extension. It works with all scenarios of testing (switching project, creating terminals, opening editors and so on) and configurations (with or without r.path.windows set). No orphans processes in sights. At least for me, I hope other users can confirm it. TLDR; Troubleshooting History Starting from these quotes: From @renkun-ken
From @albertosantini
I cloned the hello world extension and replaced the content of My workflow was starting a debugging session of the extension, opening the command palette, executing I played with different approach: with spawn or with exec, with libraries killing processes (fkill, tree-kill, taskkill, etc.), with another native kill executable (pskill). Just to understand if the problem was related with R.exe (32bit or 64bit) or Rterm.exe, with the way I killed the processes, with the disposing logic of the extension or vscode. During the journey, I learned you cannot use any of the libs out there, to kill a tree of processes in the disposing function, because all use the async approach. Generally speaking, in the disposing function you need to use only a sync approach. |
|
Great finding and the details! If @Yunuuuu could confirm it also works, we could merge this PR (again). |
|
Perfect! Thanks for the excellent method! I have tested it can work for both |


What problem did you solve?
Follows #936