mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #8860 from lucc/nvim_get_proc
This commit is contained in:
commit
768bc68d7e
@ -13,7 +13,7 @@ local function _os_proc_info(pid)
|
|||||||
if pid == nil or pid <= 0 or type(pid) ~= 'number' then
|
if pid == nil or pid <= 0 or type(pid) ~= 'number' then
|
||||||
error('invalid pid')
|
error('invalid pid')
|
||||||
end
|
end
|
||||||
local cmd = { 'ps', '-p', pid, '-o', 'ucomm=', }
|
local cmd = { 'ps', '-p', pid, '-o', 'comm=', }
|
||||||
local err, name = _system(cmd)
|
local err, name = _system(cmd)
|
||||||
if 1 == err and string.gsub(name, '%s*', '') == '' then
|
if 1 == err and string.gsub(name, '%s*', '') == '' then
|
||||||
return {} -- Process not found.
|
return {} -- Process not found.
|
||||||
@ -23,7 +23,7 @@ local function _os_proc_info(pid)
|
|||||||
end
|
end
|
||||||
local _, ppid = _system({ 'ps', '-p', pid, '-o', 'ppid=', })
|
local _, ppid = _system({ 'ps', '-p', pid, '-o', 'ppid=', })
|
||||||
-- Remove trailing whitespace.
|
-- Remove trailing whitespace.
|
||||||
name = string.gsub(name, '%s+$', '')
|
name = string.gsub(string.gsub(name, '%s+$', ''), '^.*/', '')
|
||||||
ppid = string.gsub(ppid, '%s+$', '')
|
ppid = string.gsub(ppid, '%s+$', '')
|
||||||
ppid = tonumber(ppid) == nil and -1 or tonumber(ppid)
|
ppid = tonumber(ppid) == nil and -1 or tonumber(ppid)
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user