diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c index 7cd87f53b3c..61569fda9a6 100644 --- a/dlls/kernelbase/console.c +++ b/dlls/kernelbase/console.c @@ -2307,33 +2307,45 @@ void init_console( void ) COORD size; if (is_tty_handle( params->hStdInput )) - { tty_in = params->hStdInput; - params->hStdInput = NULL; - } if (is_tty_handle( params->hStdOutput )) - { tty_out = params->hStdOutput; - params->hStdOutput = NULL; - } - if (is_tty_handle( params->hStdError )) - { - if (tty_out) CloseHandle( params->hStdError ); - else tty_out = params->hStdError; - params->hStdError = NULL; - } + else if (is_tty_handle( params->hStdError )) + tty_out = params->hStdError; size.X = params->dwXCountChars; size.Y = params->dwYCountChars; TRACE( "creating unix console (size %u %u)\n", size.X, size.Y ); params->ConsoleHandle = create_pseudo_console( size, tty_in, tty_out, NULL, 0, &process ); - CloseHandle( process ); - CloseHandle( tty_in ); - CloseHandle( tty_out ); - - if (params->ConsoleHandle && create_console_connection( params->ConsoleHandle )) + if (params->ConsoleHandle) + { + CloseHandle( process ); + + if (is_tty_handle( params->hStdInput )) + { + CloseHandle( params->hStdInput ); + params->hStdInput = NULL; + } + if (is_tty_handle( params->hStdOutput )) + { + CloseHandle( params->hStdOutput ); + params->hStdOutput = NULL; + } + if (is_tty_handle( params->hStdError )) + { + CloseHandle( params->hStdError ); + params->hStdError = NULL; + } + + if (params->ConsoleHandle && create_console_connection( params->ConsoleHandle )) + { + init_console_std_handles( FALSE ); + } + } + else { - init_console_std_handles( FALSE ); + WARN( "Failed to create console process\n" ); + params->ConsoleHandle = CONSOLE_HANDLE_SHELL_NO_WINDOW; } } else if (params->ConsoleHandle == CONSOLE_HANDLE_ALLOC ||