diff --git a/main.cpp b/main.cpp index 6dc9ae980..c4bba3bc6 100644 --- a/main.cpp +++ b/main.cpp @@ -14,6 +14,8 @@ #if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) #include #include +#elif defined (_WIN32) +#include #endif #define ANSI_COLOR_RED "\x1b[31m" @@ -753,7 +755,7 @@ bool llama_eval( static bool is_interacting = false; -#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) +#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) || defined (_WIN32) void sigint_handler(int signo) { if (signo == SIGINT) { if (!is_interacting) { @@ -863,6 +865,8 @@ int main(int argc, char ** argv) { sigemptyset (&sigint_action.sa_mask); sigint_action.sa_flags = 0; sigaction(SIGINT, &sigint_action, NULL); +#elif defined (_WIN32) + signal(SIGINT, sigint_handler); #endif fprintf(stderr, "%s: interactive mode on.\n", __func__); @@ -892,9 +896,7 @@ int main(int argc, char ** argv) { if (params.interactive) { fprintf(stderr, "== Running in interactive mode. ==\n" -#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) " - Press Ctrl+C to interject at any time.\n" -#endif " - Press Return to return control to LLaMa.\n" " - If you want to submit another line, end your input in '\\'.\n"); } @@ -1037,6 +1039,9 @@ int main(int argc, char ** argv) { } } +#if defined (_WIN32) + signal(SIGINT, SIG_DFL); +#endif // report timing {