mirror of https://github.com/neovim/neovim.git
Compare commits
3 Commits
99a38741d3
...
f5a4a1ff79
Author | SHA1 | Date |
---|---|---|
Jongwook Choi | f5a4a1ff79 | |
dundargoc | c18d7941ef | |
Jongwook Choi | 91aa36cf10 |
|
@ -50,11 +50,6 @@ file(GLOB DOCFILES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)
|
|||
set_directory_properties(PROPERTIES
|
||||
EP_PREFIX "${DEPS_BUILD_DIR}")
|
||||
|
||||
find_program(CCACHE_PRG ccache)
|
||||
if(CCACHE_PRG)
|
||||
set(CMAKE_C_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E env CCACHE_SLOPPINESS=pch_defines,time_macros ${CCACHE_PRG})
|
||||
endif()
|
||||
|
||||
if(NOT CI_BUILD)
|
||||
set(CMAKE_INSTALL_MESSAGE NEVER)
|
||||
endif()
|
||||
|
|
|
@ -23,6 +23,12 @@ if(POLICY CMP0092)
|
|||
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_POLICY_DEFAULT_CMP0092=NEW)
|
||||
endif()
|
||||
|
||||
find_program(CACHE_PRG NAMES ccache sccache)
|
||||
if(CACHE_PRG)
|
||||
set(CMAKE_C_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E env CCACHE_SLOPPINESS=pch_defines,time_macros ${CACHE_PRG})
|
||||
list(APPEND DEPS_CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER_LAUNCHER:STRING=${CMAKE_C_COMPILER_LAUNCHER})
|
||||
endif()
|
||||
|
||||
# MAKE_PRG
|
||||
if(UNIX)
|
||||
find_program(MAKE_PRG NAMES gmake make)
|
||||
|
@ -58,7 +64,8 @@ function(get_externalproject_options name DEPS_IGNORE_SHA)
|
|||
|
||||
set(EXTERNALPROJECT_OPTIONS
|
||||
DOWNLOAD_NO_PROGRESS TRUE
|
||||
EXTERNALPROJECT_OPTIONS URL ${${name_allcaps}_URL})
|
||||
EXTERNALPROJECT_OPTIONS URL ${${name_allcaps}_URL}
|
||||
CMAKE_CACHE_ARGS ${DEPS_CMAKE_CACHE_ARGS})
|
||||
|
||||
if(NOT ${DEPS_IGNORE_SHA})
|
||||
list(APPEND EXTERNALPROJECT_OPTIONS URL_HASH SHA256=${${name_allcaps}_SHA256})
|
||||
|
|
|
@ -1780,15 +1780,15 @@ vim.system({cmd}, {opts}, {on_exit}) *vim.system()*
|
|||
will be written to stdin and closed. Defaults to `false`.
|
||||
• stdout: (boolean|function) Handle output from stdout.
|
||||
When passed as a function must have the signature
|
||||
`fun(err: string, data: string)`. Defaults to `true`
|
||||
`fun(err: string, data: string)`. Defaults to `true`.
|
||||
• stderr: (boolean|function) Handle output from stderr.
|
||||
When passed as a function must have the signature
|
||||
`fun(err: string, data: string)`. Defaults to `true`.
|
||||
• text: (boolean) Handle stdout and stderr as text.
|
||||
Replaces `\r\n` with `\n`.
|
||||
• 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.
|
||||
• timeout: (integer) Run the command with a time limit
|
||||
(given in milliseconds). 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
|
||||
|
@ -1805,15 +1805,16 @@ vim.system({cmd}, {opts}, {on_exit}) *vim.system()*
|
|||
(`vim.SystemObj`) Object with the fields:
|
||||
• cmd (string[]) Command name and args
|
||||
• pid (integer) Process ID
|
||||
• 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. Cannot be called in
|
||||
|api-fast|.
|
||||
• 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
|
||||
• wait (fun(timeout: integer|nil): vim.SystemCompleted) Wait for the
|
||||
process to complete, for {timeout} milliseconds (if {timeout} is
|
||||
given) or the timeout specified in {opts}. Upon timeout the process
|
||||
is sent the TERM signal (15) and the exit code is set to 124. Cannot
|
||||
be called in |api-fast|.
|
||||
• vim.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|string))
|
||||
• write (fun(data: string|nil)) Requires `stdin=true`. Pass `nil` to
|
||||
close the stream.
|
||||
|
|
|
@ -105,13 +105,13 @@ vim.log = {
|
|||
--- and closed. Defaults to `false`.
|
||||
--- - stdout: (boolean|function)
|
||||
--- Handle output from stdout. When passed as a function must have the signature `fun(err: string, data: string)`.
|
||||
--- Defaults to `true`
|
||||
--- Defaults to `true`.
|
||||
--- - stderr: (boolean|function)
|
||||
--- Handle output from stderr. When passed as a function must have the signature `fun(err: string, data: string)`.
|
||||
--- Defaults to `true`.
|
||||
--- - text: (boolean) Handle stdout and stderr as text. Replaces `\r\n` with `\n`.
|
||||
--- - 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.
|
||||
--- - timeout: (integer) Run the command with a time limit (given in milliseconds).
|
||||
--- 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 running after the
|
||||
--- parent exits. Note that the child process will still keep the parent's event loop alive
|
||||
|
@ -123,14 +123,15 @@ vim.log = {
|
|||
--- @return vim.SystemObj Object with the fields:
|
||||
--- - cmd (string[]) Command name and args
|
||||
--- - pid (integer) Process ID
|
||||
--- - 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. Cannot
|
||||
--- be called in |api-fast|.
|
||||
--- - 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
|
||||
--- - wait (fun(timeout: integer|nil): vim.SystemCompleted) Wait for the process to complete,
|
||||
--- for {timeout} milliseconds (if {timeout} is given) or the timeout specified in {opts}.
|
||||
--- Upon timeout the process is sent the TERM signal (15) and the exit code is set to 124.
|
||||
--- Cannot be called in |api-fast|.
|
||||
--- - vim.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|string))
|
||||
--- - write (fun(data: string|nil)) Requires `stdin=true`. Pass `nil` to close the stream.
|
||||
--- - is_closing (fun(): boolean)
|
||||
|
|
|
@ -90,19 +90,24 @@ end
|
|||
|
||||
local MAX_TIMEOUT = 2 ^ 31
|
||||
|
||||
--- @param timeout? integer
|
||||
--- @param timeout? integer timeout (in milliseconds), must be >= 0.
|
||||
--- @return vim.SystemCompleted
|
||||
function SystemObj:wait(timeout)
|
||||
local state = self._state
|
||||
|
||||
local done = vim.wait(timeout or state.timeout or MAX_TIMEOUT, function()
|
||||
-- If timeout == 0, vim.wait() will return immediately and uv timer won't schedule on_exit()
|
||||
-- in which state.result will be set
|
||||
timeout = math.max(1, timeout or state.timeout or MAX_TIMEOUT)
|
||||
|
||||
local done = vim.wait(timeout, function()
|
||||
return state.result ~= nil
|
||||
end, nil, true)
|
||||
|
||||
if not done then
|
||||
-- Send sigkill since this cannot be caught
|
||||
self:_timeout(SIG.KILL)
|
||||
vim.wait(timeout or state.timeout or MAX_TIMEOUT, function()
|
||||
-- Send SIGTERM since this cannot be caught
|
||||
self:_timeout(SIG.TERM)
|
||||
-- wait a bit more until state.result is set
|
||||
vim.wait(timeout, function()
|
||||
return state.result ~= nil
|
||||
end, nil, true)
|
||||
end
|
||||
|
|
|
@ -75,7 +75,7 @@ describe('vim.system', function()
|
|||
it('supports timeout', function()
|
||||
eq({
|
||||
code = 124,
|
||||
signal = 15,
|
||||
signal = 15, -- SIGTERM
|
||||
stdout = '',
|
||||
stderr = '',
|
||||
}, system({ 'sleep', '10' }, { timeout = 1000 }))
|
||||
|
@ -83,6 +83,18 @@ describe('vim.system', function()
|
|||
end)
|
||||
end
|
||||
|
||||
it('supports timeout = 0', function()
|
||||
local ret = exec_lua [[
|
||||
return vim.system({ 'sleep', '1' }):wait(0)
|
||||
]] --[[ @as any ]]
|
||||
eq({
|
||||
code = 124,
|
||||
signal = 15, -- SIGTERM
|
||||
stdout = '',
|
||||
stderr = '',
|
||||
}, ret)
|
||||
end)
|
||||
|
||||
it('kill processes', function()
|
||||
exec_lua([[
|
||||
local signal
|
||||
|
|
Loading…
Reference in New Issue