nim-lang / choosenim

Official tool for easily installing and managing multiple versions of the Nim programming language.
BSD 3-Clause "New" or "Revised" License
35 stars 7 forks source link

choosenim causes child nimsuggest processes not to be killed on server shutdown, when using nimlangserver #13

Open RokkuCode opened 2 months ago

RokkuCode commented 2 months ago

(Copy from https://github.com/dom96/choosenim/issues/339)

This issue is currently breaking the user experience with Nim and vscode. Users who simply want to try Nim and install Nim and vscode with the langserver + plugin are faced with the problem that it does not work and throws errors. Maybe a solution would be to temporarily abandon the proxy binaries and just use symlinks on Linux as seen in a fork of choosenim under https://github.com/ire4ever1190/choosenim/pull/18/files


Here's the original issue, reported in the nimlangserver:

https://github.com/nim-lang/langserver/issues/184

It turned out this issue only occurs when choosenim is used. When nimlangserver is shut down, it sends SIGTERM signals to its nimsuggest child processes. Since choosenim inserts a proxy process between the real nimsuggest and nimlangserver, when the server is shut down, only the proxy is killed, leaving the real nimsuggest processes running and consuming memory.

I think the choosenim proxy should be modified in such a way, so that it doesn't leave processes running, when it's killed. One way to do it is to handle the SIGTERM signal (and the equivalent on Windows). Another possible solution is to use the execve() family of functions to spawn the real nimsuggest process, thus replacing the proxy process with the real nimsuggest, using the same process id.