unix/windows: Disable sigaction on windows port.
This commit is contained in:
parent
b0b0012fd8
commit
c76af32575
13
unix/main.c
13
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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user