comparison 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
comparison
equal deleted inserted replaced
3215:bc3fdfe311a3 3216:60a89a69a70a
165 } 165 }
166 166
167 // Fix up things before exiting. 167 // Fix up things before exiting.
168 168
169 void 169 void
170 clean_up_for_exit (void)
171 {
172 command_editor::restore_terminal_state ();
173
174 // XXX FIXME XXX -- is this needed? Can it cause any trouble?
175 raw_mode (0);
176
177 command_history::clean_up_and_save ();
178
179 close_plot_stream ();
180
181 close_files ();
182
183 cleanup_tmp_files ();
184
185 flush_octave_stdout ();
186
187 if (!quitting_gracefully && (interactive || forced_interactive))
188 cout << "\n";
189 }
190
191 void
192 clean_up_and_exit (int retval) 170 clean_up_and_exit (int retval)
193 { 171 {
194 clean_up_for_exit (); 172 do_octave_atexit ();
195 173
196 exit (retval == EOF ? 0 : retval); 174 exit (retval == EOF ? 0 : retval);
197 } 175 }
198 176
199 DEFUN_TEXT (casesen, args, , 177 DEFUN_TEXT (casesen, args, ,
507 SLStack<string> octave_atexit_functions; 485 SLStack<string> octave_atexit_functions;
508 486
509 void 487 void
510 do_octave_atexit (void) 488 do_octave_atexit (void)
511 { 489 {
490 static bool deja_vu = false;
491
512 while (! octave_atexit_functions.empty ()) 492 while (! octave_atexit_functions.empty ())
513 { 493 {
514 octave_value_list fcn = octave_atexit_functions.pop (); 494 octave_value_list fcn = octave_atexit_functions.pop ();
515 495
516 feval (fcn, 0); 496 feval (fcn, 0);
517 497
518 flush_octave_stdout (); 498 flush_octave_stdout ();
499 }
500
501 if (! deja_vu)
502 {
503 deja_vu = true;
504
505 command_editor::restore_terminal_state ();
506
507 // XXX FIXME XXX -- is this needed? Can it cause any trouble?
508 raw_mode (0);
509
510 command_history::clean_up_and_save ();
511
512 close_plot_stream ();
513
514 close_files ();
515
516 cleanup_tmp_files ();
517
518 flush_octave_stdout ();
519
520 if (!quitting_gracefully && (interactive || forced_interactive))
521 cout << "\n";
519 } 522 }
520 } 523 }
521 524
522 DEFUN (atexit, args, , 525 DEFUN (atexit, args, ,
523 "atexit (NAME): register NAME as a function to call when Octave exits\n\ 526 "atexit (NAME): register NAME as a function to call when Octave exits\n\