3434#include <sys/stat.h>
3535#include <sys/types.h>
3636#include <errno.h>
37- #include <signal.h>
3837
3938#include "mpconfig.h"
4039#include "nlr.h"
@@ -65,6 +64,9 @@ mp_uint_t mp_verbose_flag = 0;
6564long heap_size = 128 * 1024 * (sizeof (mp_uint_t ) / 4 );
6665#endif
6766
67+ #ifndef _WIN32
68+ #include <signal.h>
69+
6870STATIC mp_obj_t keyboard_interrupt_obj ;
6971
7072STATIC void sighandler (int signum ) {
@@ -78,6 +80,7 @@ STATIC void sighandler(int signum) {
7880 sigaction (SIGINT , & sa , NULL );
7981 }
8082}
83+ #endif
8184
8285#define FORCED_EXIT (0x100)
8386// returns standard error codes: 0 for success, 1 for all other errors
@@ -134,23 +137,29 @@ STATIC int execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind,
134137 return 0 ;
135138 }
136139
140+ #ifndef _WIN32
137141 // enable signal handler
138142 struct sigaction sa ;
139143 sa .sa_handler = sighandler ;
140144 sigemptyset (& sa .sa_mask );
141145 sigaction (SIGINT , & sa , NULL );
142146 sa .sa_handler = SIG_DFL ;
147+ #endif
143148
144149 // execute it
145150 nlr_buf_t nlr ;
146151 if (nlr_push (& nlr ) == 0 ) {
147152 mp_call_function_0 (module_fun );
153+ #ifndef _WIN32
148154 sigaction (SIGINT , & sa , NULL );
155+ #endif
149156 nlr_pop ();
150157 return 0 ;
151158 } else {
152159 // uncaught exception
160+ #ifndef _WIN32
153161 sigaction (SIGINT , & sa , NULL );
162+ #endif
154163 // check for SystemExit
155164 mp_obj_t exc = (mp_obj_t )nlr .ret_val ;
156165 if (mp_obj_is_subclass_fast (mp_obj_get_type (exc ), & mp_type_SystemExit )) {
@@ -329,8 +338,10 @@ int main(int argc, char **argv) {
329338
330339 mp_init ();
331340
341+ #ifndef _WIN32
332342 // create keyboard interrupt object
333343 keyboard_interrupt_obj = mp_obj_new_exception (& mp_type_KeyboardInterrupt );
344+ #endif
334345
335346 char * home = getenv ("HOME" );
336347 char * path = getenv ("MICROPYPATH" );
0 commit comments