mfussenegger / nvim-lint

An asynchronous linter plugin for Neovim complementary to the built-in Language Server Protocol support.
GNU General Public License v3.0
1.77k stars 191 forks source link

Processes are not being properly terminated #521

Closed lewis6991 closed 4 months ago

lewis6991 commented 5 months ago

Ok so this issue is a tricky one I've been debugging for a few hours and relates closely to https://github.com/neovim/neovim/issues/24567

Problem

So basically today I noticed my machine tanking whilst working on a python project setup to run pylint with nvim-lint. After running ps x I noticed there were 100's of zombie pylint processes.

I debugged lua/lint.lua and found nothing wrong with the logic so I dug deeper.

What I found can be illustrated with:

So basically running sigterm on a pid of a running script doesn't kill any of its subprocesses.

And this is exactly what was happening with nvim-lint and pylint since pylint is implemented as a python script with the contents:

#!/devtools/homebrew/opt/python@3.11/bin/python3.11
# -*- coding: utf-8 -*-
import re
import sys
from pylint import run_pylint
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(run_pylint())

Possible solutions

Launching the process detached = true and switching sigterm to sigkill will resolve this, however sigkill is quite aggressive.

So additionally, I propose we first issue sigint and then set up a timer until the process is closed. If it isn't closed by a certain duration, then hit it with a sigkill.