fix(vim.system): let on_exit handle cleanup after kill

Fixes #25000
This commit is contained in:
Lewis Russell
2023-09-03 10:17:24 +01:00
parent 6abc608445
commit a44521f46e
2 changed files with 29 additions and 6 deletions

View File

@@ -54,4 +54,28 @@ describe('vim.system', function()
end)
end
it('kill processes', function()
exec_lua([[
local signal
local cmd = vim.system({ 'cat', '-' }, { stdin = true }, function(r)
signal = r.signal
end) -- run forever
cmd:kill('sigint')
-- wait for the process not to exist
local done = vim.wait(2000, function()
return signal ~= nil
end)
assert(done, 'process did not exit')
-- Check the process is no longer running
vim.fn.systemlist({'ps', 'p', tostring(cmd.pid)})
assert(vim.v.shell_error == 1, 'dwqdqd '..vim.v.shell_error)
assert(signal == 2)
]])
end)
end)