Change to replace stderr with conout

This commit is contained in:
erw7 2019-11-22 13:51:14 +09:00 committed by Björn Linse
parent 4e06594c53
commit c86d5fa981
2 changed files with 6 additions and 3 deletions

View File

@ -482,7 +482,7 @@ uint64_t channel_from_stdio(bool rpc, CallbackReader on_output,
stdin_dup_fd = os_dup(STDIN_FILENO);
os_replace_stdin_to_conin();
stdout_dup_fd = os_dup(STDOUT_FILENO);
os_replace_stdout_to_conout();
os_replace_stdout_and_stderr_to_conout();
}
#endif
rstream_init_fd(&main_loop, &channel->stream.stdio.in, stdin_dup_fd, 0);

View File

@ -24,9 +24,8 @@ void os_replace_stdin_to_conin(void)
assert(conin_fd == STDIN_FILENO);
}
void os_replace_stdout_to_conout(void)
void os_replace_stdout_and_stderr_to_conout(void)
{
close(STDOUT_FILENO);
const HANDLE conout_handle =
CreateFile("CONOUT$",
GENERIC_READ | GENERIC_WRITE,
@ -34,6 +33,10 @@ void os_replace_stdout_to_conout(void)
(LPSECURITY_ATTRIBUTES)NULL,
OPEN_EXISTING, 0, (HANDLE)NULL);
assert(conout_handle != INVALID_HANDLE_VALUE);
close(STDOUT_FILENO);
const int conout_fd = _open_osfhandle((intptr_t)conout_handle, 0);
assert(conout_fd == STDOUT_FILENO);
close(STDERR_FILENO);
const int conerr_fd = _open_osfhandle((intptr_t)conout_handle, 0);
assert(conerr_fd == STDERR_FILENO);
}