From 18e01f777063462d1c67190fbb265fb920ebd063 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 7 Nov 2011 14:05:31 -0800 Subject: [PATCH] vm: enqueue signals for FEP signals too Although SIGINT still can't interrupt the current Factor thread in a sane way, this will at least wake up the run loop when waiting for input and fix #348 when implemented at the application level. --- vm/os-unix.cpp | 2 +- vm/os-windows.cpp | 2 +- vm/safepoints.cpp | 4 +++- vm/safepoints.hpp | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index 6e7ba34180..d76d92fa16 100755 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -193,7 +193,7 @@ void fep_signal_handler(int signal, siginfo_t *siginfo, void *uap) { factor_vm *vm = current_vm_p(); if (vm) - vm->safepoint.enqueue_fep(); + vm->safepoint.enqueue_fep(signal); else fatal_error("Foreign thread received signal", signal); } diff --git a/vm/os-windows.cpp b/vm/os-windows.cpp index d949d2fb55..c2be26c422 100755 --- a/vm/os-windows.cpp +++ b/vm/os-windows.cpp @@ -289,7 +289,7 @@ static BOOL WINAPI ctrl_handler(DWORD dwCtrlType) threads. */ assert(thread_vms.size() == 1); factor_vm *vm = thread_vms.begin()->second; - vm->safepoint.enqueue_fep(); + vm->safepoint.enqueue_fep(0); return TRUE; } default: diff --git a/vm/safepoints.cpp b/vm/safepoints.cpp index 55a76c6852..bec10898ed 100644 --- a/vm/safepoints.cpp +++ b/vm/safepoints.cpp @@ -8,11 +8,13 @@ void safepoint_state::enqueue_safepoint() volatile parent->code->guard_safepoint(); } -void safepoint_state::enqueue_fep() volatile +void safepoint_state::enqueue_fep(cell signal) volatile { if (parent->fep_p) fatal_error("Low-level debugger interrupted", 0); atomic::store(&fep_p, true); + if (signal != 0) + atomic::store(&queued_signal, signal); enqueue_safepoint(); } diff --git a/vm/safepoints.hpp b/vm/safepoints.hpp index a97ad8499f..4acef6ab20 100644 --- a/vm/safepoints.hpp +++ b/vm/safepoints.hpp @@ -21,7 +21,7 @@ struct safepoint_state void enqueue_safepoint() volatile; void enqueue_samples(cell samples, cell pc, bool foreign_thread_p) volatile; - void enqueue_fep() volatile; + void enqueue_fep(cell signal) volatile; // os-*.cpp void enqueue_signal(cell signal) volatile;