diff --git a/nvim/child_process_stream.lua b/nvim/child_process_stream.lua index d7c35e5..3d1fc1d 100644 --- a/nvim/child_process_stream.lua +++ b/nvim/child_process_stream.lua @@ -62,7 +62,9 @@ function ChildProcessStream:close(signal) self._proc:kill('sig'..signal) end - uv.run() + while not self.exitcode do + uv.run('once') + end assert(self.exitcode) native.pid_wait(self._pid) end diff --git a/test/session_spec.lua b/test/session_spec.lua index 73fbfef..cd37db5 100644 --- a/test/session_spec.lua +++ b/test/session_spec.lua @@ -257,3 +257,11 @@ describe('stdio', function() assert.are.same({'notification', 'd', {6, 7}}, session:next_message()) end) end) + +it('closing session does not hang with active loop', function() + local cmd = {nvim_prog, '-u', 'NONE', '--embed', '--headless'} + local session1 = Session.new(ChildProcessStream.spawn(cmd)) + local session2 = Session.new(ChildProcessStream.spawn(cmd)) + session1:close() + session2:close() +end)