diff src/toplev.cc @ 3216:60a89a69a70a

[project @ 1998-11-11 20:47:03 by jwe]
author jwe
date Wed, 11 Nov 1998 20:47:43 +0000
parents bc3fdfe311a3
children be8e0ba13644
line wrap: on
line diff
--- a/src/toplev.cc	Tue Nov 10 14:12:07 1998 +0000
+++ b/src/toplev.cc	Wed Nov 11 20:47:43 1998 +0000
@@ -167,31 +167,9 @@
 // Fix up things before exiting.
 
 void
-clean_up_for_exit (void)
-{
-  command_editor::restore_terminal_state ();
-
-  // XXX FIXME XXX -- is this needed?  Can it cause any trouble?
-  raw_mode (0);
-
-  command_history::clean_up_and_save ();
-
-  close_plot_stream ();
-
-  close_files ();
-
-  cleanup_tmp_files ();
-
-  flush_octave_stdout ();
-
-  if (!quitting_gracefully && (interactive || forced_interactive))
-    cout << "\n";
-}
-
-void
 clean_up_and_exit (int retval)
 {
-  clean_up_for_exit ();
+  do_octave_atexit ();
 
   exit (retval == EOF ? 0 : retval);
 }
@@ -509,6 +487,8 @@
 void
 do_octave_atexit (void)
 {
+  static bool deja_vu = false;
+
   while (! octave_atexit_functions.empty ())
     {
       octave_value_list fcn = octave_atexit_functions.pop ();
@@ -517,6 +497,29 @@
 
       flush_octave_stdout ();
     }
+
+  if (! deja_vu)
+    {
+      deja_vu = true;
+
+      command_editor::restore_terminal_state ();
+
+      // XXX FIXME XXX -- is this needed?  Can it cause any trouble?
+      raw_mode (0);
+
+      command_history::clean_up_and_save ();
+
+      close_plot_stream ();
+
+      close_files ();
+
+      cleanup_tmp_files ();
+
+      flush_octave_stdout ();
+
+      if (!quitting_gracefully && (interactive || forced_interactive))
+	cout << "\n";
+    }
 }
 
 DEFUN (atexit, args, ,