vm: close the console when exiting

This prevents an endless loop caused by the nvidia drivers on linux.
See http://www.nvnews.net/vbulletin/showthread.php?t=164619
db4
Philipp Brüschweiler 2011-11-12 22:06:47 +01:00 committed by Joe Groff
parent b9a358a1df
commit db19efe1b3
4 changed files with 15 additions and 0 deletions

View File

@ -496,6 +496,15 @@ void factor_vm::open_console()
pthread_mutex_init(&stdin_mutex, NULL);
}
// This method is used to kill the stdin_loop before exiting from factor.
// A Nvidia driver bug on Linux is the reason this has to be done, see:
// http://www.nvnews.net/vbulletin/showthread.php?t=164619
void factor_vm::close_console()
{
pthread_mutex_lock(&stdin_mutex);
pthread_kill(stdin_thread, SIGTERM);
}
void factor_vm::lock_console()
{
// Lock the stdin_mutex and send the stdin_loop thread a signal to interrupt

View File

@ -317,6 +317,10 @@ void factor_vm::unlock_console()
{
}
void factor_vm::close_console()
{
}
void factor_vm::sampler_thread_loop()
{
LARGE_INTEGER counter, new_counter, units_per_second;

View File

@ -5,6 +5,7 @@ namespace factor
void factor_vm::primitive_exit()
{
close_console();
exit((int)to_fixnum(ctx->pop()));
}

View File

@ -732,6 +732,7 @@ struct factor_vm
void start_sampling_profiler_timer();
void end_sampling_profiler_timer();
void open_console();
void close_console();
void lock_console();
void unlock_console();
static void abort();