mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 23:49:19 +08:00
fix(job): close stdout/stderr on exit
This commit is contained in:
parent
94c1dd4557
commit
7da557c1f8
@ -95,10 +95,25 @@ function M.start(cmd, opts)
|
||||
local exit_cb
|
||||
if opts.on_exit then
|
||||
exit_cb = function(code, singin)
|
||||
if stdout and stdout:is_active() then
|
||||
stdout:close()
|
||||
end
|
||||
if stderr and stderr:is_active() then
|
||||
stderr:close()
|
||||
end
|
||||
vim.schedule(function()
|
||||
opts.on_exit(current_id, code, singin)
|
||||
end)
|
||||
end
|
||||
else
|
||||
exit_cb = function(code, singin)
|
||||
if stdout and stdout:is_active() then
|
||||
stdout:close()
|
||||
end
|
||||
if stderr and stderr:is_active() then
|
||||
stderr:close()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local handle, pid = uv.spawn(command, opt, exit_cb)
|
||||
@ -223,16 +238,6 @@ function M.stop(id)
|
||||
if stdin and stdin:is_active() then
|
||||
stdin:close()
|
||||
end
|
||||
-- close stdio
|
||||
local stdout = jobobj.state.stout
|
||||
if stdout and stdout:is_active() then
|
||||
stdout:close()
|
||||
end
|
||||
-- close stdio
|
||||
local stderr = jobobj.state.stderr
|
||||
if stderr and stderr:is_active() then
|
||||
stderr:close()
|
||||
end
|
||||
|
||||
local handle = jobobj.handle
|
||||
handle:kill(6)
|
||||
|
Loading…
x
Reference in New Issue
Block a user