diff options
author | erw7 <erw7.github@gmail.com> | 2019-11-16 13:45:37 +0900 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2020-01-17 11:36:28 +0100 |
commit | 2c8016c7048051da9afd809b580cf8f2d2c69614 (patch) | |
tree | 30020e865a94cd6c3e19ff346a1c16fa5f62cbd3 /src/nvim/channel.c | |
parent | 60c7eabb2feeb95f405deca6680bdd59113edcaa (diff) | |
download | rneovim-2c8016c7048051da9afd809b580cf8f2d2c69614.tar.gz rneovim-2c8016c7048051da9afd809b580cf8f2d2c69614.tar.bz2 rneovim-2c8016c7048051da9afd809b580cf8f2d2c69614.zip |
Add stdin, stdout replacement functions
Diffstat (limited to 'src/nvim/channel.c')
-rw-r--r-- | src/nvim/channel.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/nvim/channel.c b/src/nvim/channel.c index b9ea36d397..b346845c66 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -13,6 +13,7 @@ #include "nvim/os/shell.h" #ifdef WIN32 # include "nvim/os/os_win_conpty.h" +# include "nvim/os/os_win_console.h" #endif #include "nvim/path.h" #include "nvim/ascii.h" @@ -479,23 +480,9 @@ uint64_t channel_from_stdio(bool rpc, CallbackReader on_output, // stdin and stdout with CONIN$ and CONOUT$, respectively. if (embedded_mode && os_has_conpty_working()) { stdin_dup_fd = os_dup(STDIN_FILENO); - close(STDIN_FILENO); - const HANDLE conin_handle = - CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES)NULL, - OPEN_EXISTING, 0, (HANDLE)NULL); - assert(conin_handle != INVALID_HANDLE_VALUE); - const int conin_fd = _open_osfhandle((intptr_t)conin_handle, _O_RDONLY); - assert(conin_fd == STDIN_FILENO); + os_replace_stdin_to_conin(); stdout_dup_fd = os_dup(STDOUT_FILENO); - close(STDOUT_FILENO); - const HANDLE conout_handle = - CreateFile("CONOUT$", GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES)NULL, - OPEN_EXISTING, 0, (HANDLE)NULL); - assert(conout_handle != INVALID_HANDLE_VALUE); - const int conout_fd = _open_osfhandle((intptr_t)conout_handle, 0); - assert(conout_fd == STDOUT_FILENO); + os_replace_stdout_to_conout(); } #endif rstream_init_fd(&main_loop, &channel->stream.stdio.in, stdin_dup_fd, 0); |