Revert back to GetStdHandle, since it works fine with pipes.
Also include the formerly-missing NULL check, since this can fail in two ways.
This commit is contained in:
parent
bd8fe5868f
commit
3af1387b18
@ -301,8 +301,8 @@ open_console(UI *ui)
|
|||||||
tty_in = stdin;
|
tty_in = stdin;
|
||||||
tty_out = stderr;
|
tty_out = stderr;
|
||||||
|
|
||||||
HANDLE handle = (HANDLE)_get_osfhandle(_fileno(stdin));
|
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
if (handle != INVALID_HANDLE_VALUE) {
|
if (handle != NULL && handle != INVALID_HANDLE_VALUE) {
|
||||||
if (GetFileType(handle) == FILE_TYPE_CHAR)
|
if (GetFileType(handle) == FILE_TYPE_CHAR)
|
||||||
return GetConsoleMode(handle, &console_mode);
|
return GetConsoleMode(handle, &console_mode);
|
||||||
else
|
else
|
||||||
@ -314,8 +314,8 @@ open_console(UI *ui)
|
|||||||
static int
|
static int
|
||||||
noecho_console(UI *ui)
|
noecho_console(UI *ui)
|
||||||
{
|
{
|
||||||
HANDLE handle = (HANDLE)_get_osfhandle(_fileno(stdin));
|
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
if (handle != INVALID_HANDLE_VALUE) {
|
if (handle != NULL && handle != INVALID_HANDLE_VALUE) {
|
||||||
if (GetFileType(handle) == FILE_TYPE_CHAR)
|
if (GetFileType(handle) == FILE_TYPE_CHAR)
|
||||||
return SetConsoleMode(handle, console_mode & ~ENABLE_ECHO_INPUT);
|
return SetConsoleMode(handle, console_mode & ~ENABLE_ECHO_INPUT);
|
||||||
else
|
else
|
||||||
@ -327,8 +327,8 @@ noecho_console(UI *ui)
|
|||||||
static int
|
static int
|
||||||
echo_console(UI *ui)
|
echo_console(UI *ui)
|
||||||
{
|
{
|
||||||
HANDLE handle = (HANDLE)_get_osfhandle(_fileno(stdin));
|
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
if (handle != INVALID_HANDLE_VALUE) {
|
if (handle != NULL && handle != INVALID_HANDLE_VALUE) {
|
||||||
if (GetFileType(handle) == FILE_TYPE_CHAR)
|
if (GetFileType(handle) == FILE_TYPE_CHAR)
|
||||||
return SetConsoleMode(handle, console_mode);
|
return SetConsoleMode(handle, console_mode);
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user