Skip to content

Commit ad0f01b

Browse files
authored
Merge pull request ggml-org#56 from anzz1/patch-2
2 parents 60c84e6 + 1b19586 commit ad0f01b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

chat.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -887,11 +887,12 @@ int main(int argc, char ** argv) {
887887
sigaction(SIGINT, &sigint_action, NULL);
888888
#elif defined (_WIN32)
889889
signal(SIGINT, sigint_handler);
890-
//Windows console ANSI color fix
891-
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
892-
DWORD mode;
893-
GetConsoleMode(hConsole, &mode);
894-
SetConsoleMode(hConsole, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
890+
891+
// Windows console ANSI color fix
892+
DWORD mode = 0;
893+
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
894+
if (hConsole && hConsole != INVALID_HANDLE_VALUE && GetConsoleMode(hConsole, &mode))
895+
SetConsoleMode(hConsole, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
895896
#endif
896897

897898
fprintf(stderr, "%s: interactive mode on.\n", __func__);

0 commit comments

Comments
 (0)