|
14 | 14 | #if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
|
15 | 15 | #include <signal.h>
|
16 | 16 | #include <unistd.h>
|
| 17 | +#elif defined (_WIN32) |
| 18 | +#include <signal.h> |
17 | 19 | #endif
|
18 | 20 |
|
19 | 21 | #define ANSI_COLOR_RED "\x1b[31m"
|
@@ -755,7 +757,7 @@ bool llama_eval(
|
755 | 757 |
|
756 | 758 | static bool is_interacting = false;
|
757 | 759 |
|
758 |
| -#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) |
| 760 | +#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) || defined (_WIN32) |
759 | 761 | void sigint_handler(int signo) {
|
760 | 762 | printf(ANSI_COLOR_RESET);
|
761 | 763 | if (signo == SIGINT) {
|
@@ -865,6 +867,8 @@ int main(int argc, char ** argv) {
|
865 | 867 | sigemptyset (&sigint_action.sa_mask);
|
866 | 868 | sigint_action.sa_flags = 0;
|
867 | 869 | sigaction(SIGINT, &sigint_action, NULL);
|
| 870 | +#elif defined (_WIN32) |
| 871 | + signal(SIGINT, sigint_handler); |
868 | 872 | #endif
|
869 | 873 |
|
870 | 874 | fprintf(stderr, "%s: interactive mode on.\n", __func__);
|
@@ -894,7 +898,7 @@ int main(int argc, char ** argv) {
|
894 | 898 |
|
895 | 899 | if (params.interactive) {
|
896 | 900 | fprintf(stderr, "== Running in interactive mode. ==\n"
|
897 |
| -#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) |
| 901 | +#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) || defined (_WIN32) |
898 | 902 | " - Press Ctrl+C to interject at any time.\n"
|
899 | 903 | #endif
|
900 | 904 | " - Press Return to return control to LLaMa.\n"
|
@@ -1039,6 +1043,9 @@ int main(int argc, char ** argv) {
|
1039 | 1043 | }
|
1040 | 1044 | }
|
1041 | 1045 |
|
| 1046 | +#if defined (_WIN32) |
| 1047 | + signal(SIGINT, SIG_DFL); |
| 1048 | +#endif |
1042 | 1049 |
|
1043 | 1050 | // report timing
|
1044 | 1051 | {
|
|
0 commit comments