]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: don't SIGQUIT on unix or Ctrl-Break on windows
authorJoe Groff <arcata@gmail.com>
Thu, 10 Nov 2011 21:46:44 +0000 (13:46 -0800)
committerJoe Groff <arcata@gmail.com>
Fri, 11 Nov 2011 00:01:07 +0000 (16:01 -0800)
This gives us an escape hatch for when things go way south and ^C can't be handled. Also unmask SIGQUIT and SIGTERM from the stdin_loop thread so the thread doesn't keep the process alive after those signals.

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

index 84bcf43122dfc81f4dcb992e47668e76946ffea8..085745ce37e693eccb0512d7be267074c71bfd04 100755 (executable)
@@ -337,7 +337,6 @@ void factor_vm::unix_init_signals()
 #endif
 
        init_sigaction_with_handler(&fep_sigaction, fep_signal_handler);
-       sigaction_safe(SIGQUIT,&fep_sigaction,NULL);
        sigaction_safe(SIGINT,&fep_sigaction,NULL);
 
        init_sigaction_with_handler(&sample_sigaction, sample_signal_handler);
@@ -431,6 +430,8 @@ void *stdin_loop(void *arg)
        sigfillset(&mask);
        sigdelset(&mask, SIGUSR2);
        sigdelset(&mask, SIGTTIN);
+       sigdelset(&mask, SIGTERM);
+       sigdelset(&mask, SIGQUIT);
        pthread_sigmask(SIG_SETMASK, &mask, NULL);
 
        while(loop_running)
index a16ad6176e161ca8d03b49ad722c065c34e7d910..42a9dc4da7b4da7cecac32b3b66cc956d1c7c6d3 100755 (executable)
@@ -280,17 +280,16 @@ static BOOL WINAPI ctrl_handler(DWORD dwCtrlType)
 {
        switch (dwCtrlType) {
        case CTRL_C_EVENT:
-       case CTRL_BREAK_EVENT:
-       {
-               /* The CtrlHandler runs in its own thread without stopping the main thread.
-               Since in practice nobody uses the multi-VM stuff yet, we just grab the first
-               VM we can get. This will not be a good idea when we actually support native
-               threads. */
-               assert(thread_vms.size() == 1);
-               factor_vm *vm = thread_vms.begin()->second;
-               vm->safepoint.enqueue_fep(vm);
-               return TRUE;
-       }
+               {
+                       /* The CtrlHandler runs in its own thread without stopping the main thread.
+                       Since in practice nobody uses the multi-VM stuff yet, we just grab the first
+                       VM we can get. This will not be a good idea when we actually support native
+                       threads. */
+                       assert(thread_vms.size() == 1);
+                       factor_vm *vm = thread_vms.begin()->second;
+                       vm->safepoint.enqueue_fep(vm);
+                       return TRUE;
+               }
        default:
                return FALSE;
        }