Use a thread status flag to indicate interrupt status instead of trying to raise from the signal handler

This commit is contained in:
K. Lange 2021-03-04 08:23:13 +09:00
parent 37353c2b88
commit 88c6d27569
3 changed files with 7 additions and 1 deletions

View File

@ -522,7 +522,7 @@ _dbgQuit:
static void handleSigint(int sigNum) {
if (krk_currentThread.frameCount) {
krk_runtimeError(vm.exceptions->keyboardInterrupt, "Keyboard interrupt.");
krk_currentThread.flags |= KRK_THREAD_SIGNALLED;
}
signal(sigNum, handleSigint);

View File

@ -1800,6 +1800,11 @@ static KrkValue run() {
if (krk_currentThread.flags & KRK_THREAD_SINGLE_STEP) {
krk_debuggerHook(frame);
}
if (krk_currentThread.flags & KRK_THREAD_SIGNALLED) {
krk_runtimeError(vm.exceptions->keyboardInterrupt, "Keyboard interrupt.");
goto _finishException;
}
#endif
#ifdef ENABLE_WATCHDOG

View File

@ -226,6 +226,7 @@ typedef struct KrkVM {
#define KRK_THREAD_ENABLE_SCAN_TRACING (1 << 2)
#define KRK_THREAD_HAS_EXCEPTION (1 << 3)
#define KRK_THREAD_SINGLE_STEP (1 << 4)
#define KRK_THREAD_SIGNALLED (1 << 5)
/* Global flags */
#define KRK_GLOBAL_ENABLE_STRESS_GC (1 << 8)