Commit Graph

10455 Commits

Author SHA1 Message Date
b-r-o-c-k
c49dac7cd3 build: Fix CMake target dependency problem
nvim was being ran before its runtime dependencies were copied.
2018-03-18 12:51:39 -05:00
b-r-o-c-k
feee814b30 build/windows: Add CMakeLists.txt for gperf 2018-03-18 12:51:39 -05:00
b-r-o-c-k
229604213e build/windows: Add CMake script to generate headers for Libvterm
On Windows the CMake script will replace the Perl script used by
Libvterm to generate headers.
2018-03-18 12:51:30 -05:00
b-r-o-c-k
15c53a44d3 build/windows: Add CMakeLists.txt for Libuv on Windows
Adding a CMakeLists.txt for Libuv removes the need for Python
when building on Windows.
2018-03-18 12:50:39 -05:00
b-r-o-c-k
bf789b04f3 build/windows: Ignore whitespace when applying patches
The --ignore-whitespace argument was added when applying patches to
prevent failures when patched files have different line endings.
2018-03-18 12:50:39 -05:00
Justin M. Keyes
4e02f1ab87
Merge #8107 'jobs: separate process-group' 2018-03-18 18:36:02 +01:00
Matthieu Coudron
0848add488 screen.c: define column width by function (#5802)
This does not change the behavior but centralizes column size for future use
(like dynamic signcolumn width depending on the maximum number of signs on a line).

The returned value is limited by the size of the `extra` tab in win_line
(currently allows for 18 ASCII characters).
2018-03-18 17:31:28 +01:00
Justin M. Keyes
ae409b5042 test/win: use cmd.exe for test
Can revert this after #8120.
2018-03-18 17:15:06 +01:00
Justin M. Keyes
167898a517 test: jobstop() kills entire process tree
Test correctly fails before 8d90171f8b.
ref #6530
2018-03-18 17:03:05 +01:00
Justin M. Keyes
72e4c9d8e7
Merge #8142 'build/msvc: fix some warnings' 2018-03-18 16:47:25 +01:00
Justin M. Keyes
65b66bc332 build/MSVC: fix "C4005: RGB: macro redefinition" 2018-03-18 14:30:05 +01:00
Justin M. Keyes
26b84a8b3e build/MSVC: fix "C4003: not enough actual parameters for macro"
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.
2018-03-18 14:30:05 +01:00
Justin M. Keyes
960f093625 build/MSVC: fix "C4028: formal parameter different from declaration" 2018-03-18 14:11:39 +01:00
Justin M. Keyes
66a8b593e7 ci/travis: report cache size 2018-03-18 14:11:39 +01:00
Justin M. Keyes
8f82f95c1c ci/travis: also cache $DEPS_DOWNLOAD_DIR
ref #5166
2018-03-18 14:11:38 +01:00
Justin M. Keyes
a034d4b69d API: nvim_get_proc()
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;
+}
2018-03-18 00:11:45 +01:00
Justin M. Keyes
b0e5187e49 ci/travis: Don't destroy cache during prepare
This change was missed in c7f95fde1b.
ref #5166
2018-03-17 14:26:34 +01:00
KunMing Xie
f407a94032 vim-patch:8.0.0344: unlet command leaks memory (#8141)
Problem:    Unlet command leaks memory. (Nikolai Pavlov)
Solution:   Free the memory on error. (closes vim/vim#1497)
49439c4cdf
2018-03-17 09:49:06 +01:00
Justin M. Keyes
330e5acbce win: nvim_get_proc_children()
TODO: Raymond Chen explains[1] racy behavior of the
CreateToolhelp32Snapshot approach.  Better approach:

> create a job object and put process P in it. Then call
> QueryInformationJobObject with JobObjectBasicProcessIdList to get the
> list of child processes.

[1] "Why is CreateToolhelp32Snapshot returning incorrect parent process IDs all of a sudden?"
    https://blogs.msdn.microsoft.com/oldnewthing/20150403-00/?p=44313
2018-03-16 10:55:12 +01:00
Justin M. Keyes
12af7016e2 nvim_get_proc_children: fallback to shell
/proc/…/children may be unavailable because of an unset kernel option.
Fallback to `pgrep` invoked in a shell.
2018-03-16 10:55:12 +01:00
Justin M. Keyes
dbad797edd API: nvim_get_proc_children()
ref https://github.com/libuv/libuv/pull/836
2018-03-16 10:55:12 +01:00
Justin M. Keyes
de86f82483 win: os_proc_tree_kill()
XXX: comment at https://stackoverflow.com/q/1173342 :
> Windows recycles PIDs quite fast, you have to be extra careful not
> to kill unrelated processes. These APIs will report PPIDs for long
> dead processes whose PIDs may have been recycled. Check the parent
> start date to make sure it is related to the processes you spawned.
2018-03-16 10:55:12 +01:00
Justin M. Keyes
8d90171f8b jobs: child proc must have a separate process-group
UV_PROCESS_DETACHED compels libuv:uv__process_child_init() to call
setsid() in the child just after fork().  That ensures the process and
its descendants are grouped in a separate session (and process group).

The following jobstart() call correctly groups `sh` and `sleep` in a new
session (and process-group), where `sh` is the "session leader" (and
process-group leader):

    :call jobstart(['sh','-c','sleep 60'])

     SESN  PGRP   PID  PPID  Command
    30383 30383 30383  3620  │  ├─ -bash
    30383 31432 31432 30383  │  │  └─ nvim -u NORC
    30383 31432 31433 30383  │  │     ├─ nvim -u NORC
     8105  8105  8105 31432  │  │     └─ sh -c sleep 60
     8105  8105  8106  8105  │  │        └─ sleep 60

closes #6530
ref: https://stackoverflow.com/q/1046933
ref: https://unix.stackexchange.com/a/404065

Helped-by: Marco Hinz <mh.codebro+github@gmail.com>

Discussion
------------------------------------------------------------------------

On my linux box before this patch, the termclose_spec.lua:'kills job
trapping SIGTERM' test indirectly causes cmake/busted to wait for 60s.
That's because the test spawns a `sleep 60` descendant process which
hangs around even after nvim exits: nvim killed the parent PID, but not
PGID (process-group), so the grandchild "reparented" to init (PID 1).

Session contains processes (and process-groups) which are logically part
of the same "login session". Process-group is a set of
logically/informally-related processes within a session; for example,
shells assign a process group to each "job". Session IDs and PGIDs both
have type pid_t (like PIDs).

These OS-level mechanisms are, as usual, legacy accidents whose purpose
is upheld by convention and folklore.  We can use session-level grouping
(setsid), or we could use process-group-level grouping (setpgid).

Vim uses setsid() if available, otherwise setpgid(0,0).

Windows
------------------------------------------------------------------------

UV_PROCESS_DETACHED on win32 sets CREATE_NEW_PROCESS_GROUP flag.
But uv_kill() does not kill the process-group:
https://github.com/nodejs/node/issues/3617

Ideas:
- Set UV_PROCESS_DETACHED (CREATE_NEW_PROCESS_GROUP), then call
  GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, pid)
   - Maybe won't work because MSDN says "Only processes that share the
     same console as the calling process receive the signal."
     https://docs.microsoft.com/en-us/windows/console/generateconsolectrlevent
     But CREATE_NEW_PROCESS_GROUP creates a new console ...
     ref https://stackoverflow.com/q/1453520
- Group processes within a "job". libuv does that *globally* for
  non-detached processes: uv__init_global_job_handle.
- Iterate through CreateToolhelp32Snapshot().
   - https://stackoverflow.com/q/1173342
   - Vim does this, see terminate_all()
2018-03-16 10:55:12 +01:00
Justin M. Keyes
de47515477 test: use luv.now() instead of os.time() 2018-03-16 10:55:12 +01:00
Marco Hinz
cca407b43e DirChanged: support <buffer> (#8140) 2018-03-16 07:29:20 +01:00
Justin M. Keyes
0093c25dd3 doc: nodejs 2018-03-15 04:59:18 +01:00
chemzqm
338664e96c node/provider: support g:node_host_prog #8135 2018-03-15 04:55:48 +01:00
KunMing Xie
5ce8158a5d vim-patch:8.0.0316: :help z? does not work (#8134)
Problem:    ":help z?" does not work. (Pavol Juhas)
Solution:   Remove exception for z?.
dad7309dd2
2018-03-14 10:30:24 +01:00
James McCoy
f5b0f5e17f
Merge pull request #8127 from jamessan/update-pvs-headers
Add missing PVS headers to new files
2018-03-11 20:17:28 -04:00
b-r-o-c-k
e24e98534b ci/AppVeyor: use PowerShell (#8124) 2018-03-11 23:44:07 +01:00
James McCoy
4e5e6506b5
pvscheck: Ignore exit code of pvs-studio-analyzer
Since its typically non-zero, the script immediately exits instead of
converting the binary log into useful formats.
2018-03-11 18:01:44 -04:00
James McCoy
8bd1bbcec8
Add missing PVS headers to new files 2018-03-11 17:24:09 -04:00
Justin M. Keyes
c7f95fde1b ci/travis: Don't destroy cache during prepare
Use `cp -r` instead of `mv`.
Remove use of `dirname`, that was missed in 10cdf8c286.

closes #5166
2018-03-11 20:29:20 +01:00
Justin M. Keyes
241c380da9
Merge #8117 'build/CI/MSVC/LuaRocks' 2018-03-11 19:53:05 +01:00
KunMing Xie
a2d1e9cc79 vim-patch:8.0.0262,8.0.0263 (#8123)
vim-patch:8.0.0262: Farsi support is barely tested
Problem:    Farsi support is barely tested.
Solution:   Add more tests for Farsi.  Clean up the code.
ddf662a1c8

vim-patch:8.0.0263: Farsi support is not tested enough
Problem:    Farsi support is not tested enough.
Solution:   Add more tests for Farsi.  Clean up the code.
80627cf51f
2018-03-11 19:22:58 +01:00
Justin M. Keyes
b0b656dd37 ci/travis: rename $BUILD_NVIM_DEPS to $CACHE_ENABLE 2018-03-11 15:38:18 +01:00
Justin M. Keyes
9a0147754c build: respect $DEPS_BUILD_DIR
Without this, the CI_TARGET=lint travis job cant't find the cached deps
(in $HOME/nvim-deps), nor can it update the cache.
2018-03-11 15:38:18 +01:00
Justin M. Keyes
45e81e03f8 ci/macOS: skip python2 on travis macOS
macOS travis builds recently started failing (travis caches were cleared
recently, maybe related). python2 is reasonably covered by linux CI. Not
going to waste time on it for macOS CI.

    ==> Installing python@2
    ==> Downloading https://homebrew.bintray.com/bottles/python@2-2.7.14_3.el_capita
    ==> Pouring python@2-2.7.14_3.el_capitan.bottle.tar.gz
    Error: The `brew link` step did not complete successfully
    The formula built, but is not symlinked into /usr/local
    Could not symlink bin/2to3-2
    Target /usr/local/bin/2to3-2
    is a symlink belonging to python. You can unlink it:
      brew unlink python
    To force the link and overwrite all conflicting files:
      brew link --overwrite python@2
    To list all files that would be deleted:
      brew link --overwrite --dry-run python@2
    Possible conflicting files are:
    /usr/local/bin/2to3-2 -> /usr/local/Cellar/python/2.7.12_1/bin/2to3-2
    /usr/local/bin/2to3-2.7 -> /usr/local/Cellar/python/2.7.12_1/bin/2to3-2.7
    /usr/local/bin/idle -> /usr/local/Cellar/python/2.7.12_1/bin/idle
    ...
2018-03-11 12:45:15 +01:00
Justin M. Keyes
968c7ab17e ci/travis: use ninja instead of make 2018-03-11 12:45:15 +01:00
Justin M. Keyes
ffad8d4c51 ci/AppVeyor: disable MSVC_32 build
The MSVC_32 currently hangs.  When MSVC becomes the primary Windows
target, we can enable MSVC_32 and retire one of the mingw builds.  In
the meantime it adds too much time.
2018-03-11 12:43:42 +01:00
Justin M. Keyes
de919b9b94 build/luarocks: avoid parallelism for luarocks build
Is there a race between the luarocks `make bootstrap` dependencies?

reverts f73b4911312b35bfe38ed068672a2f8ba8875ba7
ref https://github.com/luarocks/luarocks/pull/774
2018-03-11 12:43:42 +01:00
Justin M. Keyes
90963a9c55 build/luarocks: apply "Fix siteconfig" patch
upstream: https://github.com/luarocks/luarocks/pull/774
2018-03-11 12:43:42 +01:00
Justin M. Keyes
496b0f944f test: next_msg(): default timeout to 10s
Infinite timeout results in hangs which waste time. If some test needs
longer than 10s to wait for a message, it should specify the timeout
explicitly.
2018-03-11 12:43:42 +01:00
Justin M. Keyes
fd4021387e test: rename next_message() to next_msg() 2018-03-11 12:43:42 +01:00
Justin M. Keyes
d554a6c7f0 ci/AppVeyor: fix set whitespace quoting 2018-03-11 12:43:42 +01:00
Justin M. Keyes
2bf0869160 test: handle non-deterministic message cadence 2018-03-11 12:43:42 +01:00
James McCoy
9154782386
Merge pull request #8122 from jamessan/appimagev2
Create v2 AppImages and include update information
2018-03-09 22:06:57 -05:00
James McCoy
9dc3cc2c68
genappimage: Include update information for releases/nightlies
This will allow users to use AppImageUpdate to update their AppImage.
It requires publishing the created zsync file alongside the appimage
file for the releases.
2018-03-09 20:49:26 -05:00
James McCoy
e1f27cdb4c
genappimage: Create a type 2 AppImage 2018-03-09 20:49:26 -05:00
James McCoy
b0d08998f5
genappimage: Use AppImage/AppImages repo to avoid redirects 2018-03-09 20:49:24 -05:00