Skip to content

Fix parent process being killed on Windows when checking if it's alive #445

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

Merged
merged 3 commits into from
Sep 3, 2019
Merged

Fix parent process being killed on Windows when checking if it's alive #445

merged 3 commits into from
Sep 3, 2019

Conversation

deathaxe
Copy link
Contributor

@deathaxe deathaxe commented Nov 3, 2018

Fixes #434

The os.kill() function being used to check for the existence of the parent process causes the owning process to be killed on Windows platforms.

This commit therefore introduces an alternative solution to check for the parent process to be alive by using the Windows API types.windll.kernel32.OpenProcess()

An alternative would have been to introduce psutil library as another dependency, which was judged not being worth.

Fixes issue #434

The `os.kill()` function being used to check for the existence of the
parent process causes the owning process to be killed on Windows
platforms.

This commit therefore introduces an alternative solution to check for
the parent process to be alive by using the Windows API

  types.windll.kernel32.OpenProcess()

An alternative would have been to introduce psutil library as another
dependency, which was judged not being worth.
@rwols
Copy link
Contributor

rwols commented Nov 15, 2018

ping @gatesn @jiahuijiang ?

@ccordoba12
Copy link
Contributor

I think this was wrongly closed.

@jiahuijiang
Copy link

Right now if you run python language server without passing a --check-parent-process flag it will not check the parent process aliveness anymore

@deathaxe
Copy link
Contributor Author

... but if you do so on Windows, the parent process is still killed due to invalid usage of os.kill().

This flag just asks the user to actively trigger the still existing bug, by passing the flag.

@ccordoba12
Copy link
Contributor

Yeah, that's why I think this should be reopened.

jsenin pushed a commit to jsenin/python-language-server that referenced this pull request Dec 18, 2018
@CAM-Gerlach
Copy link

CAM-Gerlach commented Feb 27, 2019

This fix is critical on Windows; its apparently leading to many instances of zombie PyLS processes sticking around and taking up substantial memory and resources until the system is rebooted or the user knows to manually find and kill them. This and other stalled/rejected patches has forced us to maintain our own downstream fork, but we'd like to see these important fixes merged upstream to benefit all your users as well. Thanks!

@ccordoba12
Copy link
Contributor

ccordoba12 commented Feb 27, 2019

This and other stalled/rejected patches has forced us to maintain our own downstream fork

@gatesn, he's talking about Spyder (@CAM-Gerlach is one of our developers). We haven't decided yet if we would have to create a fork of this project for Spyder, but we will certainly have to if things like this PR are finally rejected.

Could you consider reviewing your decision? Thanks!

@ccordoba12
Copy link
Contributor

@andfoy, please create another PR based on this one and resubmit it to this repo so we can merge it. This basically makes the parent process check mechanism work on Windows.

@ccordoba12
Copy link
Contributor

@deathaxe, we have to that because tests are not passing here.

@ccordoba12
Copy link
Contributor

@deathaxe, or if you're still interested in merging this PR, please rebase it.

@ccordoba12 ccordoba12 reopened this Aug 30, 2019
@ccordoba12 ccordoba12 added this to the 0.29.0 milestone Aug 30, 2019
@ccordoba12
Copy link
Contributor

@deathaxe, @andfoy, please forget about my comments above. I forgot I could update this PR myself.

@ccordoba12 ccordoba12 changed the title Fix parent process being killed on Windows (#434) Fix parent process being killed on Windows Aug 30, 2019
@ccordoba12 ccordoba12 removed this from the 0.28.3 milestone Sep 2, 2019
@ccordoba12 ccordoba12 added this to the 0.28.3 milestone Sep 2, 2019
@ccordoba12
Copy link
Contributor

Thanks a lot @deathaxe for your contribution!

@ccordoba12 ccordoba12 changed the title Fix parent process being killed on Windows Fix parent process being killed on Windows when checking if it's alive Sep 3, 2019
@ccordoba12 ccordoba12 merged commit 65d6fd2 into palantir:develop Sep 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server crashes immediately with Neovim Language Client on Windows
5 participants