From 1d16bba4d8b8b648d2dabd610924bcf3051a0f29 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 7 Jan 2023 10:06:03 +0100 Subject: 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. --- src/nvim/main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/nvim/main.c') diff --git a/src/nvim/main.c b/src/nvim/main.c index 9bb9eea4f6..953385836b 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -279,6 +279,15 @@ int main(int argc, char **argv) // argument list "global_alist". command_line_scan(¶ms); +#ifndef MSWIN + int tty_fd = params.input_isatty + ? STDIN_FILENO + : (params.output_isatty + ? STDOUT_FILENO + : (params.err_isatty ? STDERR_FILENO : -1)); + pty_process_save_termios(tty_fd); +#endif + nlua_init(argv, argc, params.lua_arg0); TIME_MSG("init lua interpreter"); @@ -1455,14 +1464,6 @@ static void check_and_set_isatty(mparm_T *paramp) stdout_isatty = paramp->output_isatty = os_isatty(STDOUT_FILENO); paramp->err_isatty = os_isatty(STDERR_FILENO); -#ifndef MSWIN - int tty_fd = paramp->input_isatty - ? STDIN_FILENO - : (paramp->output_isatty - ? STDOUT_FILENO - : (paramp->err_isatty ? STDERR_FILENO : -1)); - pty_process_save_termios(tty_fd); -#endif TIME_MSG("window checked"); } -- cgit