aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua
Commit message (Collapse)AuthorAge
* Merge #8107 'jobs: separate process-group'Justin M. Keyes2018-03-18
|\
| * API: nvim_get_proc()Justin M. Keyes2018-03-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TODO: "exepath" field (win32: QueryFullProcessImageName()) On unix-likes `ps` is used because the platform-specific APIs are a nightmare. For reference, below is a (incomplete) attempt: diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c index 09769925aca5..99afbbf290c1 100644 --- a/src/nvim/os/process.c +++ b/src/nvim/os/process.c @@ -208,3 +210,60 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count) return 0; } +/// Gets various properties of the process identified by `pid`. +/// +/// @param pid Process to inspect. +/// @return Map of process properties, empty on error. +Dictionary os_proc_info(int pid) +{ + Dictionary pinfo = ARRAY_DICT_INIT; +#ifdef WIN32 + +#elif defined(__APPLE__) + char buf[PROC_PIDPATHINFO_MAXSIZE]; + if (proc_pidpath(pid, buf, sizeof(buf))) { + name = getName(buf); + PUT(pinfo, "exepath", STRING_OBJ(cstr_to_string(buf))); + return name; + } else { + ILOG("proc_pidpath() failed for pid: %d", pid); + } +#elif defined(BSD) +# if defined(__FreeBSD__) +# define KP_COMM(o) o.ki_comm +# else +# define KP_COMM(o) o.p_comm +# endif + struct kinfo_proc *proc = kinfo_getproc(pid); + if (proc) { + PUT(pinfo, "name", cstr_to_string(KP_COMM(proc))); + xfree(proc); + } else { + ILOG("kinfo_getproc() failed for pid: %d", pid); + } + +#elif defined(__linux__) + char fname[256] = { 0 }; + char buf[MAXPATHL]; + snprintf(fname, sizeof(fname), "/proc/%d/comm", pid); + FILE *fp = fopen(fname, "r"); + // FileDescriptor *f = file_open_new(&error, fname, kFileReadOnly, 0); + // ptrdiff_t file_read(FileDescriptor *const fp, char *const ret_buf, + // const size_t size) + if (fp == NULL) { + ILOG("fopen() of /proc/%d/comm failed", pid); + } else { + size_t n = fread(buf, sizeof(char), sizeof(buf) - 1, fp); + if (n == 0) { + WLOG("fread() of /proc/%d/comm failed", pid); + } else { + size_t end = MIN(sizeof(buf) - 1, n); + end = (end > 0 && buf[end - 1] == '\n') ? end - 1 : end; + buf[end] = '\0'; + PUT(pinfo, "name", STRING_OBJ(cstr_to_string(buf))); + } + } + fclose(fp); +#endif + return pinfo; +}
| * nvim_get_proc_children: fallback to shellJustin M. Keyes2018-03-16
| | | | | | | | | | /proc/…/children may be unavailable because of an unset kernel option. Fallback to `pgrep` invoked in a shell.
* | build/MSVC: fix "C4003: not enough actual parameters for macro"Justin M. Keyes2018-03-18
|/ | | | | | For the case of TV_DICTITEM_STRUCT, we can't just pass `1` because: https://github.com/neovim/neovim/pull/8142#discussion_r175262436 > this variant will trigger array overrun warnings from various static analyzers.
* lua/executor: Remove all places where lightuserdata is usedZyX2018-01-21
| | | | | | Should fix problems with luajit+arm64. Fixes #7879 Ref LuaJIT/LuaJIT#230
* *: Provide list length when allocating listsZyX2018-01-14
|
* eval,lua/converter: Fix problems spotted in reviewZyX2017-12-31
|
* *: Remove most calls to tv_list_item_allocZyX2017-12-24
| | | | Still left calls in eval/typval.c and test/unit/eval/helpers.lua. Latter is the only reason why function did not receive `static` modifier.
* *: Hide list implementation in other files as wellZyX2017-12-10
|
* *: Start hiding list implementationZyX2017-12-10
| | | | Most of files, except for eval.c and eval/* were only processed by perl.
* docJustin M. Keyes2017-11-06
|
* Merge #7165 'lua: Move stricmp to vim module'Justin M. Keyes2017-10-22
|\
| * lua/executor: Fix crash when first string contains NUL and second notZyX2017-08-15
| |
| * lua/executor: Move stricmp to vim “module” and document itZyX2017-08-15
| |
| * lua/executor: Make stricmp function work with strings with NULsZyX2017-08-15
|/
* lua/executor: Fix crash when printing empty string (#7157)Nikolai Aleksandrovich Pavlov2017-08-13
|
* Merge #6789 from ZyX-I/lua-pathJustin M. Keyes2017-06-27
|\ | | | | lua: Add paths from &runtimepath to package.path and package.cpath
| * lua: Use automatic determining of suffixes only for package.cpathZyX2017-05-28
| |
| * lua: Add paths from &runtimepath to package.path and package.cpathZyX2017-05-25
| |
* | lint: fix indentation of FUNC_ATTR linesBjörn Linse2017-06-03
|/
* lua: Add PVS comment to lua/*.cZyX2017-05-20
|
* api: execute lua directly from the remote apiBjörn Linse2017-05-13
|
* lua/converter: Fix typo in assert condition (#6708)Nikolai Aleksandrovich Pavlov2017-05-10
| | | Ref https://github.com/neovim/neovim/pull/4411#issuecomment-300248206
* Merge branch 'master' into luaviml'/luaZyX2017-05-08
|
* lua/converter: Remove useless macrosZyX2017-04-11
|
* lua: Fix header guardsZyX2017-04-11
|
* lua: Move files from src/nvim/viml/executor to src/nvim/luaZyX2017-04-11