diff src/sighandlers.cc @ 4153:6b96ce9f5743

[project @ 2002-11-06 20:38:49 by jwe]
author jwe
date Wed, 06 Nov 2002 20:38:50 +0000
parents 01f46b36e11f
children 2e94b2abfe6d
line wrap: on
line diff
--- a/src/sighandlers.cc	Wed Nov 06 18:41:50 2002 +0000
+++ b/src/sighandlers.cc	Wed Nov 06 20:38:50 2002 +0000
@@ -37,6 +37,7 @@
 #endif
 
 #include "cmd-edit.h"
+#include "quit.h"
 
 #include "error.h"
 #include "load-save.h"
@@ -53,18 +54,6 @@
 // TRUE means we can be interrupted.
 bool can_interrupt = false;
 
-// Allow us to save the signal mask and then restore it to the most
-// recently saved value.  This is necessary when using the POSIX
-// signal handling interface on some systems calling longjmp out of
-// the signal handler to get to the top level on an interrupt doesn't
-// restore the original signal mask.  Alternatively, we could use
-// sigsetjmp/siglongjmp, but saving and restoring the signal mask
-// ourselves works ok and seems simpler just now.
-
-#if defined (HAVE_POSIX_SIGNALS)
-static sigset_t octave_signal_mask;
-#endif
-
 #if RETSIGTYPE == void
 #define SIGHANDLER_RETURN(status) return
 #else
@@ -95,22 +84,6 @@
 #define OCTAVE_MEMORY_EXHAUSTED_ERROR (-1)
 #endif
 
-void
-octave_save_signal_mask (void)
-{
-#if defined (HAVE_POSIX_SIGNALS)
-  sigprocmask (0, 0, &octave_signal_mask);
-#endif
-}
-
-void
-octave_restore_signal_mask (void)
-{
-#if defined (HAVE_POSIX_SIGNALS)
-  sigprocmask (SIG_SETMASK, &octave_signal_mask, 0);
-#endif
-}
-
 static void
 my_friendly_exit (const char *sig_name, int sig_number)
 {
@@ -160,7 +133,7 @@
 
   if (can_interrupt)
     {
-      jump_to_top_level ();
+      OCTAVE_JUMP_TO_TOP_LEVEL;
       panic_impossible ();
     }
   else
@@ -268,7 +241,7 @@
 
   if (can_interrupt)
     {
-      jump_to_top_level ();
+      OCTAVE_OCTAVE_JUMP_TO_TOP_LEVEL;
       panic_impossible ();
     }
 
@@ -312,8 +285,15 @@
 
   if (can_interrupt)
     {
-      jump_to_top_level ();
+#if defined (USE_EXCEPTIONS_FOR_INTERRUPTS)
+      octave_interrupt_state = 1;
+
+      if (octave_interrupt_immediately)
+	octave_jump_to_enclosing_context ();
+#else
+      OCTAVE_JUMP_TO_TOP_LEVEL;
       panic_impossible ();
+#endif
     }
 
   SIGHANDLER_RETURN (0);
@@ -333,7 +313,7 @@
   // Don't loop forever on account of this.
 
   if (pipe_handler_error_count  > 100)
-    jump_to_top_level ();
+    OCTAVE_JUMP_TO_TOP_LEVEL;
 
   SIGHANDLER_RETURN (0);
 }