From 6d5f12efd286c684de8608c07bb0f76a9d594b5b Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 4 Sep 2023 11:30:16 +0100 Subject: fix(vim.system): make timeout work properly Mimic the behaviour of timeout(1) from coreutils. --- runtime/doc/lua.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'runtime/doc') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index f5b3e56f61..61aee559ef 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1777,7 +1777,9 @@ vim.system({cmd}, {opts}, {on_exit}) *vim.system()* `fun(err: string, data: string)`. Defaults to `true`. • text: (boolean) Handle stdout and stderr as text. Replaces `\r\n` with `\n`. - • timeout: (integer) + • timeout: (integer) Run the command with a time limit. + Upon timeout the process is sent the TERM signal (15) and + the exit code is set to 124. • detach: (boolean) If true, spawn the child process in a detached state - this will make it a process group leader, and will effectively enable the child to keep @@ -1792,14 +1794,16 @@ vim.system({cmd}, {opts}, {on_exit}) *vim.system()* Return: ~ SystemObj Object with the fields: • pid (integer) Process ID - • wait (fun(timeout: integer|nil): SystemCompleted) + • wait (fun(timeout: integer|nil): SystemCompleted) Wait for the + process to complete. Upon timeout the process is sent the KILL + signal (9) and the exit code is set to 124. • SystemCompleted is an object with the fields: • code: (integer) • signal: (integer) • stdout: (string), nil if stdout argument is passed • stderr: (string), nil if stderr argument is passed - • kill (fun(signal: integer)) + • kill (fun(signal: integer|string)) • write (fun(data: string|nil)) Requires `stdin=true`. Pass `nil` to close the stream. • is_closing (fun(): boolean) -- cgit From 80d1333b7317460c562a982ac21f900d9fbd89f6 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 4 Sep 2023 12:03:03 +0100 Subject: refactor(vim.system): factor out on_exit handling --- runtime/doc/lua.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/doc') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 61aee559ef..71f001f4fc 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1792,7 +1792,7 @@ vim.system({cmd}, {opts}, {on_exit}) *vim.system()* object, see return of SystemObj:wait(). Return: ~ - SystemObj Object with the fields: + vim.SystemObj Object with the fields: • pid (integer) Process ID • wait (fun(timeout: integer|nil): SystemCompleted) Wait for the process to complete. Upon timeout the process is sent the KILL @@ -2545,7 +2545,7 @@ vim.ui.open({path}) *vim.ui.open()* • {path} (string) Path or URL to open Return (multiple): ~ - SystemCompleted|nil Command result, or nil if not found. + vim.SystemCompleted|nil Command result, or nil if not found. (string|nil) Error message on failure See also: ~ -- cgit