process_close(): uv_unref() detached processes (#7539)

Doc for UV_PROCESS_DETACHED in uv.h mentions:
> child process will still keep the parent's event loop alive unless
> the parent process calls uv_unref() on the child's process handle.

ref #3944
This commit is contained in:
Justin M. Keyes 2017-11-12 15:34:04 +01:00 committed by GitHub
parent b6a603fe51
commit 881f9e42d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -38,7 +38,7 @@ int libuv_process_spawn(LibuvProcess *uvproc)
#endif #endif
uvproc->uvopts.exit_cb = exit_cb; uvproc->uvopts.exit_cb = exit_cb;
uvproc->uvopts.cwd = proc->cwd; uvproc->uvopts.cwd = proc->cwd;
uvproc->uvopts.env = NULL; uvproc->uvopts.env = NULL; // Inherits the parent (nvim) env.
uvproc->uvopts.stdio = uvproc->uvstdio; uvproc->uvopts.stdio = uvproc->uvstdio;
uvproc->uvopts.stdio_count = 3; uvproc->uvopts.stdio_count = 3;
uvproc->uvstdio[0].flags = UV_IGNORE; uvproc->uvstdio[0].flags = UV_IGNORE;

View File

@ -324,6 +324,13 @@ static void process_close(Process *proc)
} }
assert(!proc->closed); assert(!proc->closed);
proc->closed = true; proc->closed = true;
if (proc->detach) {
if (proc->type == kProcessTypeUv) {
uv_unref((uv_handle_t *)&(((LibuvProcess *)proc)->uv));
}
}
switch (proc->type) { switch (proc->type) {
case kProcessTypeUv: case kProcessTypeUv:
libuv_process_close((LibuvProcess *)proc); libuv_process_close((LibuvProcess *)proc);