diff --git a/src/core/ev.c b/src/core/ev.c index 89048b7e..3476937e 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -464,7 +464,9 @@ const JanetAbstractType janet_stream_type = { /* Register a fiber to resume with value */ void janet_schedule_signal(JanetFiber *fiber, Janet value, JanetSignal sig) { + if (fiber->flags & JANET_FIBER_FLAG_CANCELED) return; JanetTask t = { fiber, value, sig, ++fiber->sched_id }; + if (sig == JANET_SIGNAL_ERROR) fiber->flags |= JANET_FIBER_FLAG_CANCELED; janet_q_push(&janet_vm.spawn, &t, sizeof(t)); } @@ -1226,6 +1228,7 @@ JanetFiber *janet_loop1(void) { while (janet_vm.spawn.head != janet_vm.spawn.tail) { JanetTask task = {NULL, janet_wrap_nil(), JANET_SIGNAL_OK, 0}; janet_q_pop(&janet_vm.spawn, &task, sizeof(task)); + task.fiber->flags &= ~JANET_FIBER_FLAG_CANCELED; if (task.expected_sched_id != task.fiber->sched_id) continue; Janet res; JanetSignal sig = janet_continue_signal(task.fiber, task.value, &res, task.sig); diff --git a/src/core/fiber.h b/src/core/fiber.h index b6dcd1ba..ac2064fb 100644 --- a/src/core/fiber.h +++ b/src/core/fiber.h @@ -48,6 +48,7 @@ #define JANET_FIBER_STATUS_MASK 0x3F0000 #define JANET_FIBER_RESUME_SIGNAL 0x400000 +#define JANET_FIBER_FLAG_CANCELED 0x400000 #define JANET_FIBER_STATUS_OFFSET 16 #define JANET_FIBER_BREAKPOINT 0x1000000 diff --git a/src/core/os.c b/src/core/os.c index 9e479405..cb6b237e 100644 --- a/src/core/os.c +++ b/src/core/os.c @@ -689,12 +689,12 @@ static int janet_proc_get(void *p, Janet key, Janet *out) { *out = (NULL == proc->err) ? janet_wrap_nil() : janet_wrap_abstract(proc->err); return 1; } - #ifndef JANET_WINDOWS +#ifndef JANET_WINDOWS if (janet_keyeq(key, "pid")) { *out = janet_wrap_number(proc->pid); return 1; } - #endif +#endif if ((-1 != proc->return_code) && janet_keyeq(key, "return-code")) { *out = janet_wrap_integer(proc->return_code); return 1; diff --git a/src/mainclient/shell.c b/src/mainclient/shell.c index 7f7b84f1..839664e5 100644 --- a/src/mainclient/shell.c +++ b/src/mainclient/shell.c @@ -759,7 +759,7 @@ static int line() { case 3: /* ctrl-c */ norawmode(); kill(getpid(), SIGINT); - /* fallthrough */ + /* fallthrough */ case 17: /* ctrl-q */ gbl_cancel_current_repl_form = 1; clearlines();