std::cout << "Starting low level debugger..." << std::endl;
+ // Even though we've stopped the VM, the stdin_loop thread (see os-*.cpp)
+ // that pumps the console is still running concurrently. We lock a mutex so
+ // the thread will take a break and give us exclusive access to stdin.
lock_console();
if (!fep_help_was_shown) {
void factor_vm::lock_console()
{
+ // Lock the stdin_mutex and send the stdin_loop thread a signal to interrupt
+ // any read() it has in progress. When the stdin loop iterates again, it will
+ // try to lock the same mutex and wait until unlock_console() is called.
pthread_mutex_lock(&stdin_mutex);
pthread_kill(stdin_thread, SIGUSR2);
}