GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
quit.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2002-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include <cstring>
28 
29 #include <iostream>
30 #include <new>
31 
32 #include "quit.h"
33 
34 void (*octave_signal_hook) (void) = 0;
35 void (*octave_interrupt_hook) (void) = 0;
36 void (*octave_bad_alloc_hook) (void) = 0;
37 
38 void
40 {
43 
44  if (octave_interrupt_state > 0)
45  {
48  }
49 }
50 
51 extern OCTAVE_API void
52 clean_up_and_exit (int exit_status, bool safe_to_return)
53 {
55 
56  throw octave::exit_exception (exit_status, safe_to_return);
57 }
58 
59 void
61 {
64 
65  throw octave::interrupt_exception ();
66 }
67 
68 void
70 {
71  // FIXME: would a hook function be useful here?
72 
74 
75  throw octave::execution_exception ();
76 }
77 
78 void
80 {
83 
85 
86  throw std::bad_alloc ();
87 }
88 
89 void
91 {
93  {
96  }
97  else
98  {
99  switch (octave_exception_state)
100  {
103  break;
104 
107  break;
108 
112  break;
113 
114  default:
115  break;
116  }
117  }
118 }
sig_atomic_t octave_exit_exception_safe_to_return
Definition: cquit.c:64
void(* octave_interrupt_hook)(void)=0
Definition: quit.cc:35
void octave_throw_interrupt_exception(void)
Definition: quit.cc:60
void(* octave_bad_alloc_hook)(void)=0
Definition: quit.cc:36
sig_atomic_t octave_exit_exception_status
Definition: cquit.c:62
void octave_throw_execution_exception(void)
Definition: quit.cc:69
void octave_handle_signal(void)
Definition: quit.cc:39
OCTAVE_API void clean_up_and_exit(int exit_status, bool safe_to_return)
Definition: quit.cc:52
sig_atomic_t octave_exception_state
Definition: cquit.c:60
sig_atomic_t octave_interrupt_state
Definition: cquit.c:58
void octave_throw_bad_alloc(void)
Definition: quit.cc:79
void(* octave_signal_hook)(void)=0
Definition: quit.cc:34
void octave_rethrow_exception(void)
Definition: quit.cc:90