Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Commit

Permalink
ChildProcessStream:close: uv.run: once
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Nov 29, 2019
1 parent 63e7c9c commit 659ca84
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nvim/child_process_stream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/session_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 659ca84

Please sign in to comment.