]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: close the console when exiting
authorPhilipp Brüschweiler <blei42@gmail.com>
Sat, 12 Nov 2011 21:06:47 +0000 (22:06 +0100)
committerJoe Groff <arcata@gmail.com>
Sun, 13 Nov 2011 07:05:43 +0000 (23:05 -0800)
This prevents an endless loop caused by the nvidia drivers on linux.
See http://www.nvnews.net/vbulletin/showthread.php?t=164619

vm/os-unix.cpp
vm/os-windows.cpp
vm/run.cpp
vm/vm.hpp

index 8c6f05a920aca07b3544742845cbb405e7d7aa75..85639f8a52bb1d4b679ea43a1e608e82533d5c6f 100755 (executable)
@@ -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
index 9940850d3789536d35d89d4bcaae1af13a25d9ea..5f153e2269f556e145dabd44fcadf8408d2af841 100755 (executable)
@@ -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;
index f545340221c6ce003c308b1673e8796cf1609a8e..a56b0dd0c6c90c4a747d4205c6ebed9c4237c431 100755 (executable)
@@ -5,6 +5,7 @@ namespace factor
 
 void factor_vm::primitive_exit()
 {
+       close_console();
        exit((int)to_fixnum(ctx->pop()));
 }
 
index cfe77bd7fd646bda34cbab619fe0985927a95b26..30ec5049ecb5dd62d2effab8ba28c6235a1b3187 100755 (executable)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -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();