vm: more commentary on lock_console() stuff
parent
8337b08d0d
commit
0c58fd5c26
|
@ -459,6 +459,9 @@ void factor_vm::factorbug()
|
|||
|
||||
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) {
|
||||
|
|
|
@ -466,6 +466,9 @@ void factor_vm::open_console()
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue