diff options
author | Damien George <damien.p.george@gmail.com> | 2014-10-26 00:42:41 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-10-26 00:42:41 +0100 |
commit | c76af32575b0a897b4fdbb7b9c2d0754a8df5399 (patch) | |
tree | f7d0dc871a3ff1b8ce9a69066fa50574a44e45be /unix/main.c | |
parent | b0b0012fd8d1d0aa373a22c9fc9cdb5cb4a6dec5 (diff) | |
download | micropython-c76af32575b0a897b4fdbb7b9c2d0754a8df5399.tar.gz micropython-c76af32575b0a897b4fdbb7b9c2d0754a8df5399.zip |
unix/windows: Disable sigaction on windows port.
Diffstat (limited to 'unix/main.c')
-rw-r--r-- | unix/main.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/unix/main.c b/unix/main.c index 44542af51b..ca5dea99ac 100644 --- a/unix/main.c +++ b/unix/main.c @@ -34,7 +34,6 @@ #include <sys/stat.h> #include <sys/types.h> #include <errno.h> -#include <signal.h> #include "mpconfig.h" #include "nlr.h" @@ -65,6 +64,9 @@ mp_uint_t mp_verbose_flag = 0; long heap_size = 128*1024 * (sizeof(mp_uint_t) / 4); #endif +#ifndef _WIN32 +#include <signal.h> + STATIC mp_obj_t keyboard_interrupt_obj; STATIC void sighandler(int signum) { @@ -78,6 +80,7 @@ STATIC void sighandler(int signum) { sigaction(SIGINT, &sa, NULL); } } +#endif #define FORCED_EXIT (0x100) // 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, return 0; } + #ifndef _WIN32 // enable signal handler struct sigaction sa; sa.sa_handler = sighandler; sigemptyset(&sa.sa_mask); sigaction(SIGINT, &sa, NULL); sa.sa_handler = SIG_DFL; + #endif // execute it nlr_buf_t nlr; if (nlr_push(&nlr) == 0) { mp_call_function_0(module_fun); + #ifndef _WIN32 sigaction(SIGINT, &sa, NULL); + #endif nlr_pop(); return 0; } else { // uncaught exception + #ifndef _WIN32 sigaction(SIGINT, &sa, NULL); + #endif // check for SystemExit mp_obj_t exc = (mp_obj_t)nlr.ret_val; if (mp_obj_is_subclass_fast(mp_obj_get_type(exc), &mp_type_SystemExit)) { @@ -329,8 +338,10 @@ int main(int argc, char **argv) { mp_init(); + #ifndef _WIN32 // create keyboard interrupt object keyboard_interrupt_obj = mp_obj_new_exception(&mp_type_KeyboardInterrupt); + #endif char *home = getenv("HOME"); char *path = getenv("MICROPYPATH"); |