0.8.9.6.netbsd.2:
[sbcl.git] / src / runtime / interrupt.c
index aecee17..bae3923 100644 (file)
@@ -48,9 +48,9 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+#include "sbcl.h"
 #include "runtime.h"
 #include "arch.h"
-#include "sbcl.h"
 #include "os.h"
 #include "interrupt.h"
 #include "globals.h"
@@ -536,36 +536,52 @@ maybe_now_maybe_later(int signal, siginfo_t *info, void *void_context)
                           signal,info,context))
        return;
     interrupt_handle_now(signal, info, context);
+#ifdef LISP_FEATURE_DARWIN
+    /* Work around G5 bug */
+    sigreturn(void_context);
+#endif
 }
 
+#ifdef LISP_FEATURE_SB_THREAD
 void
 sig_stop_for_gc_handler(int signal, siginfo_t *info, void *void_context)
 {
     os_context_t *context = arch_os_get_context(&void_context);
     struct thread *thread=arch_os_get_current_thread();
     struct interrupt_data *data=thread->interrupt_data;
-
+    sigset_t ss;
+    int i;
     
     if(maybe_defer_handler(sig_stop_for_gc_handler,data,
-                          signal,info,context)){
+                          signal,info,context)) {
        return;
     }
     /* need the context stored so it can have registers scavenged */
     fake_foreign_function_call(context); 
 
+    sigemptyset(&ss);
+    for(i=1;i<NSIG;i++) sigaddset(&ss,i); /* Block everything. */
+    sigprocmask(SIG_BLOCK,&ss,0);
+
     get_spinlock(&all_threads_lock,thread->pid);
     thread->state=STATE_STOPPED;
     release_spinlock(&all_threads_lock);
-    kill(thread->pid,SIGSTOP);
+
+    sigemptyset(&ss); sigaddset(&ss,SIG_STOP_FOR_GC);
+    sigwaitinfo(&ss,0);
 
     undo_fake_foreign_function_call(context);
 }
+#endif
 
 void
 interrupt_handle_now_handler(int signal, siginfo_t *info, void *void_context)
 {
     os_context_t *context = arch_os_get_context(&void_context);
     interrupt_handle_now(signal, info, context);
+#ifdef LISP_FEATURE_DARWIN
+    sigreturn(void_context);
+#endif
 }
 
 /*
@@ -712,7 +728,7 @@ boolean handle_control_stack_guard_triggered(os_context_t *context,void *addr){
 }
 
 #ifndef LISP_FEATURE_GENCGC
-/* This function gets called from the SIGSEGV (for e.g. Linux or
+/* This function gets called from the SIGSEGV (for e.g. Linux, NetBSD, &
  * OpenBSD) or SIGBUS (for e.g. FreeBSD) handler. Here we check
  * whether the signal was due to treading on the mprotect()ed zone -
  * and if so, arrange for a GC to happen. */