Mercurial > hg > octave-lyh
diff src/toplev.cc @ 9217:ee7cf4d963f3
smarter handling of quit()
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 20 May 2009 09:52:03 +0200 |
parents | a3237ae32c0d |
children | 1c2d2c9f4a8d |
line wrap: on
line diff
--- a/src/toplev.cc +++ b/src/toplev.cc @@ -79,6 +79,8 @@ #include "variables.h" #include <version.h> +void (*octave_exit) (int) = ::exit; + // TRUE means we are exiting via the builtin exit or quit functions. static bool quitting_gracefully = false; @@ -598,6 +600,11 @@ break; } } + catch (octave_quit_exception e) + { + unwind_protect::run_all (); + clean_up_and_exit (e.status); + } catch (octave_interrupt_exception) { recover_from_exception (); @@ -632,7 +639,8 @@ sysdep_cleanup (); - exit (retval == EOF ? 0 : retval); + if (octave_exit) + (*octave_exit) (retval == EOF ? 0 : retval); } DEFUN (quit, args, nargout, @@ -660,7 +668,7 @@ exit_status = tmp; } - clean_up_and_exit (exit_status); + throw octave_quit_exception (exit_status); } else error ("quit: invalid number of output arguments");