aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/channel.c
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/channel.c
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/channel.c')
-rw-r--r--src/nvim/channel.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index f2e5a37b34..386ec832eb 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -377,6 +377,7 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, CallbackReader
} else {
has_out = rpc || callback_reader_set(chan->on_data);
has_err = callback_reader_set(chan->on_stderr);
+ proc->fwd_err = chan->on_stderr.fwd_err;
}
switch (stdin_mode) {
@@ -519,6 +520,13 @@ uint64_t channel_from_stdio(bool rpc, CallbackReader on_output, const char **err
stdout_dup_fd = os_dup(STDOUT_FILENO);
os_replace_stdout_and_stderr_to_conout();
}
+#else
+ if (embedded_mode) {
+ stdin_dup_fd = dup(STDIN_FILENO);
+ stdout_dup_fd = dup(STDOUT_FILENO);
+ dup2(STDERR_FILENO, STDOUT_FILENO);
+ dup2(STDERR_FILENO, STDIN_FILENO);
+ }
#endif
rstream_init_fd(&main_loop, &channel->stream.stdio.in, stdin_dup_fd, 0);
wstream_init_fd(&main_loop, &channel->stream.stdio.out, stdout_dup_fd, 0);