aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/system_spec.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-09-03 10:17:24 +0100
committerLewis Russell <lewis6991@gmail.com>2023-09-05 10:18:26 +0100
commita44521f46e6f79171d034e5cce1a4dc266d23e49 (patch)
tree956c8ea05033cb52d2c94cc65d4b21a72e4a4781 /test/functional/lua/system_spec.lua
parent6abc608445745e7e8def2aabf57c7a0c26b8a485 (diff)
downloadrneovim-a44521f46e6f79171d034e5cce1a4dc266d23e49.tar.gz
rneovim-a44521f46e6f79171d034e5cce1a4dc266d23e49.tar.bz2
rneovim-a44521f46e6f79171d034e5cce1a4dc266d23e49.zip
fix(vim.system): let on_exit handle cleanup after kill
Fixes #25000
Diffstat (limited to 'test/functional/lua/system_spec.lua')
-rw-r--r--test/functional/lua/system_spec.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/functional/lua/system_spec.lua b/test/functional/lua/system_spec.lua
index 836d3a83b0..35b9d5cc37 100644
--- a/test/functional/lua/system_spec.lua
+++ b/test/functional/lua/system_spec.lua
@@ -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)