Unless there is a strong reason for the current behavior, I propose that the callback which is given as the third argument to signal_start and signal_start_oneshot should receive/propagate the signal as a number. Currently, the signal is propagated as a lowercase string. This is confusing for several reasons:
- In libuv, those callbacks propagate the argument as an
int, see here
- the variable is named
signum, implying a numeric representation
- for neovim users, this presents a confusing switch in representations, see below
- the value of
uv.constants.SIGINT, and other signals, is an integer
This example demonstrates the confusion for a NeoVim user. Sure, the outputs of vim.system have no obligation to be consistent with luv, and vice versa, but it would make things simpler for us. Requires NeoVim 0.10 for the vim.uv namespace. Note also that vim.system doesn't allow SIGINT hooks (only a timeout one) so this use case is more than hypothetical.
-- Run with nvim -u NORC -l <this_file>.
-- Interrupt with C-c before 5 seconds.
local uv = vim.uv
local sigint = uv.new_signal()
sigint:start(2, function(signal)
vim.print(string.format("in handler: %s (type: %s)\n", signal, type(signal)))
end)
local job = vim.system({ "sleep", "5" }):wait()
vim.print(string.format("\nafter job exit: %s (type: %s)", job.signal, type(job.signal)))
Unless there is a strong reason for the current behavior, I propose that the callback which is given as the third argument to
signal_startandsignal_start_oneshotshould receive/propagate the signal as a number. Currently, the signal is propagated as a lowercase string. This is confusing for several reasons:int, see heresignum, implying a numeric representationuv.constants.SIGINT, and other signals, is an integerThis example demonstrates the confusion for a NeoVim user. Sure, the outputs of
vim.systemhave no obligation to be consistent with luv, and vice versa, but it would make things simpler for us. Requires NeoVim 0.10 for thevim.uvnamespace. Note also thatvim.systemdoesn't allow SIGINT hooks (only atimeoutone) so this use case is more than hypothetical.