nvim_runtime_lua

vim.SystemObj

Methods4

function SystemObj.kill(signal: string | integer) -> nil

Sends a signal to the process.

The signal can be specified as an integer or as a string.

Example:

local obj = vim.system({'sleep', '10'})
obj:kill('sigterm') -- sends SIGTERM to the process
Parameters
signalstring | integer

Signal to send to the process. See |luv-constants|.

Returns
nil
function SystemObj.wait(timeout: nil | integer) -> vim.SystemCompleted

Waits for the process to complete or until the specified timeout elapses.

This method blocks execution until the associated process has exited or the optional timeout (in milliseconds) has been reached. If the process does not exit before the timeout, it is forcefully terminated with SIGKILL (signal 9), and the exit code is set to 124.

If no timeout is provided, the method will wait indefinitely (or use the timeout specified in the options when the process was started).

Example:

local obj = vim.system({'echo', 'hello'}, { text = true })
local result = obj:wait(1000) -- waits up to 1000ms
print(result.code, result.signal, result.stdout, result.stderr)
function SystemObj.write(data: string[] | string | nil) -> nil

Writes data to the stdin of the process or closes stdin.

If data is a list of strings, each string is written followed by a newline.

If data is a string, it is written as-is.

If data is nil, the write side of the stream is shut down and the pipe is closed.

Example:

local obj = vim.system({'cat'}, { stdin = true })
obj:write({'hello', 'world'}) -- writes 'hello\nworld\n' to stdin
obj:write(nil) -- closes stdin
function SystemObj.is_closing() -> boolean

Checks if the process handle is closing or already closed.

This method returns true if the underlying process handle is either nil or is in the process of closing. It is useful for determining whether it is safe to perform operations on the process handle.

Fields2

SystemObj.cmd : string[]

Command name and args

SystemObj.pid : integer

Process ID