Skip to content

Commit 97045fb

Browse files
committed
Ignore SIGINT when talking to nvim via stdio
This is necessary because the python host runs in the same session as nvim(and receives SIGINT when the users presses ctrl+C)
1 parent 3a1f1e2 commit 97045fb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

neovim/uv_stream.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def __init__(self, address=None, port=None, spawn_argv=None):
2323
self._term.start(self._on_signal, signal.SIGTERM)
2424
self._int = pyuv.Signal(self._loop)
2525
self._int.start(self._on_signal, signal.SIGINT)
26+
self._ignore_sigint = False
2627
self._signames = dict((k, v) for v, k in signal.__dict__.items() \
2728
if v.startswith('SIG'))
2829
self._error_stream = None
@@ -59,6 +60,8 @@ def init_stdio(self):
5960
self._write_stream = pyuv.Pipe(self._loop)
6061
self._write_stream.open(sys.stdout.fileno())
6162
self._connected = True
63+
# ignore SIGINT in this mode
64+
self._ignore_sigint = True
6265

6366

6467
def init_spawn(self, argv):
@@ -96,6 +99,8 @@ def _on_connect(self, stream, error):
9699

97100

98101
def _on_signal(self, handle, signum):
102+
if self._ignore_sigint and signum == signal.SIGINT:
103+
return
99104
self.loop_stop()
100105
err = Exception('Received %s' % self._signames[signum])
101106
if not self._error_cb:

0 commit comments

Comments
 (0)