API: Use ps -o comm in nvim_get_proc()

- The POSIX version of ps(1) only specifies "comm" for the "-o" option
  but not "ucomm".  See
  http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html
- On Linux (with the procps-ng package) "ucomm" is an alias for "comm".
  See https://gitlab.com/procps-ng/procps
- OpenBSD also has "ucomm" as an alias for "comm" (with the extra note
  "Name to be used for accounting."). See https://man.openbsd.org/ps
- FreeBSD describes "ucomm" as "Name to be used for accounting." but
  does not say that it should be an alias for "comm". See
  https://www.freebsd.org/cgi/man.cgi?query=ps
This commit is contained in:
Lucas Hoffmann 2018-08-15 12:39:10 +02:00
parent ac2d661450
commit 794e7b4359

View File

@ -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.