aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/event
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-01-07 10:06:03 +0100
committerbfredl <bjorn.linse@gmail.com>2023-01-09 11:17:11 +0100
commit1d16bba4d8b8b648d2dabd610924bcf3051a0f29 (patch)
tree9ea37b95a190d055e37deabb3c556edd83bded70 /src/nvim/event
parentc19bd47c0a2e3cc77d7f5e41ed184edb41685bd3 (diff)
downloadrneovim-1d16bba4d8b8b648d2dabd610924bcf3051a0f29.tar.gz
rneovim-1d16bba4d8b8b648d2dabd610924bcf3051a0f29.tar.bz2
rneovim-1d16bba4d8b8b648d2dabd610924bcf3051a0f29.zip
fix(embed): handle stdio in server properly
Rename stdin/stdout in the server, so that RPC data won't get corrupted. This also restores the use of stderr to write directly to the terminal.
Diffstat (limited to 'src/nvim/event')
-rw-r--r--src/nvim/event/libuv_process.c3
-rw-r--r--src/nvim/event/process.c3
-rw-r--r--src/nvim/event/process.h5
3 files changed, 9 insertions, 2 deletions
diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_process.c
index 811d96ff93..10a09275d9 100644
--- a/src/nvim/event/libuv_process.c
+++ b/src/nvim/event/libuv_process.c
@@ -85,6 +85,9 @@ int libuv_process_spawn(LibuvProcess *uvproc)
uvproc->uvstdio[2].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
uvproc->uvstdio[2].data.stream = STRUCT_CAST(uv_stream_t,
&proc->err.uv.pipe);
+ } else if (proc->fwd_err) {
+ uvproc->uvstdio[2].flags = UV_INHERIT_FD;
+ uvproc->uvstdio[2].data.fd = STDERR_FILENO;
}
int status;
diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c
index 2fa789ac9a..9dfd6f329a 100644
--- a/src/nvim/event/process.c
+++ b/src/nvim/event/process.c
@@ -43,6 +43,9 @@ static int exit_need_delay = 0;
int process_spawn(Process *proc, bool in, bool out, bool err)
FUNC_ATTR_NONNULL_ALL
{
+ // forwarding stderr contradicts with processing it internally
+ assert(!(err && proc->fwd_err));
+
if (in) {
uv_pipe_init(&proc->loop->uv, &proc->in.uv.pipe, 0);
} else {
diff --git a/src/nvim/event/process.h b/src/nvim/event/process.h
index 26e03ff4f3..e0057faffb 100644
--- a/src/nvim/event/process.h
+++ b/src/nvim/event/process.h
@@ -38,7 +38,7 @@ struct process {
/// Exit handler. If set, user must call process_free().
process_exit_cb cb;
internal_process_cb internal_exit_cb, internal_close_cb;
- bool closed, detach, overlapped;
+ bool closed, detach, overlapped, fwd_err;
MultiQueue *events;
};
@@ -62,7 +62,8 @@ static inline Process process_init(Loop *loop, ProcessType type, void *data)
.closed = false,
.internal_close_cb = NULL,
.internal_exit_cb = NULL,
- .detach = false
+ .detach = false,
+ .fwd_err = false,
};
}