API: Remove path prefix from command name in nvim_get_proc()

On macOS the output from `ps -o comm` might contain the full path of the
executable.  The `ucomm` would be the basename only but is less portable
(see previous commit).
This commit is contained in:
Lucas Hoffmann 2018-08-18 14:37:29 +02:00
parent 794e7b4359
commit 4d10024a56

View File

@ -23,7 +23,7 @@ local function _os_proc_info(pid)
end
local _, ppid = _system({ 'ps', '-p', pid, '-o', 'ppid=', })
-- Remove trailing whitespace.
name = string.gsub(name, '%s+$', '')
name = string.gsub(string.gsub(name, '%s+$', ''), '^.*/', '')
ppid = string.gsub(ppid, '%s+$', '')
ppid = tonumber(ppid) == nil and -1 or tonumber(ppid)
return {