changeset 27531:478150691336

consolidate initialization code * interpreter.cc (interpreter::initialize): Set up interrupt and signal handling here instead of duplicatin that action in the execute_eval_option_code, execute_command_line_file, and main_loop methods.
author John W. Eaton <jwe@octave.org>
date Fri, 18 Oct 2019 15:40:25 -0400
parents 7a9d2b0e6da8
children 2af853f94b97
files libinterp/corefcn/interpreter.cc
diffstat 1 files changed, 13 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc	Fri Oct 18 14:31:22 2019 -0400
+++ b/libinterp/corefcn/interpreter.cc	Fri Oct 18 15:40:25 2019 -0400
@@ -655,6 +655,19 @@
 
     initialize_load_path ();
 
+    octave_save_signal_mask ();
+
+    can_interrupt = true;
+
+    octave_signal_hook = respond_to_pending_signals;
+    octave_interrupt_hook = nullptr;
+
+    catch_interrupts ();
+
+    // FIXME: could we eliminate this variable or make it not be global?
+    // Global used to communicate with signal handler.
+    octave_initialized = true;
+
     m_initialized = true;
   }
 
@@ -669,8 +682,6 @@
       {
         initialize ();
 
-        // We ignore errors in startup files.
-
         execute_startup_files ();
 
         if (m_app_context)
@@ -881,17 +892,6 @@
 
     unwind_protect frame;
 
-    octave_save_signal_mask ();
-
-    can_interrupt = true;
-
-    octave_signal_hook = respond_to_pending_signals;
-    octave_interrupt_hook = nullptr;
-
-    catch_interrupts ();
-
-    octave_initialized = true;
-
     frame.add_method (this, &interpreter::interactive, m_interactive);
 
     m_interactive = false;
@@ -927,17 +927,6 @@
 
     unwind_protect frame;
 
-    octave_save_signal_mask ();
-
-    can_interrupt = true;
-
-    octave_signal_hook = respond_to_pending_signals;
-    octave_interrupt_hook = nullptr;
-
-    catch_interrupts ();
-
-    octave_initialized = true;
-
     frame.add_method (this, &interpreter::interactive, m_interactive);
 
     string_vector args = options.all_args ();
@@ -979,17 +968,6 @@
   {
     int exit_status = 0;
 
-    octave_save_signal_mask ();
-
-    can_interrupt = true;
-
-    octave_signal_hook = respond_to_pending_signals;
-    octave_interrupt_hook = nullptr;
-
-    catch_interrupts ();
-
-    octave_initialized = true;
-
     // The big loop.
 
 #if defined (OCTAVE_ENABLE_COMMAND_LINE_PUSH_PARSER)