mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 14:28:18 +00:00
job: Refactor to ensure that all callbacks will be invoked
It's possible that a child process won't close it's standard streams, even after it exits. This can be evidenced with the "xclip" program: :call system('xclip -i -selection clipboard', 'DATA') Before this commit, the above command wouldn't return, even though the xclip program had exited. That is because `xclip` wasn't closing it's stdout/stderr streams, which would block pending_refs from ever reaching 0. Now the job.c module was refactored to ensure all streams are closed when the uv_process_t handle is closed.
This commit is contained in:
@@ -19,6 +19,15 @@ local function delete_file(name)
|
||||
end
|
||||
end
|
||||
|
||||
-- Some tests require the xclip program and a x server.
|
||||
local xclip = nil
|
||||
do
|
||||
if os.getenv('DISPLAY') then
|
||||
local proc = io.popen('which xclip')
|
||||
xclip = proc:read()
|
||||
proc:close()
|
||||
end
|
||||
end
|
||||
|
||||
describe('system()', function()
|
||||
before_each(clear)
|
||||
@@ -85,6 +94,15 @@ describe('system()', function()
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
if xclip then
|
||||
describe("with a program that doesn't close stdout", function()
|
||||
it('will exit properly after passing input', function()
|
||||
eq(nil, eval([[system('xclip -i -selection clipboard', 'clip-data')]]))
|
||||
eq('clip-data', eval([[system('xclip -o -selection clipboard')]]))
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
describe('systemlist()', function()
|
||||
@@ -140,4 +158,15 @@ describe('systemlist()', function()
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
if xclip then
|
||||
describe("with a program that doesn't close stdout", function()
|
||||
it('will exit properly after passing input', function()
|
||||
eq(nil, eval(
|
||||
"systemlist('xclip -i -selection clipboard', ['clip', 'data'])"))
|
||||
eq({'clip', 'data'}, eval(
|
||||
"systemlist('xclip -o -selection clipboard')"))
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
Reference in New Issue
Block a user