GNU Octave  3.8.0
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
cquit.c
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2003-2013 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 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include <signal.h>
28 #include <string.h>
29 
30 #include "quit.h"
31 
33 
34 void
36 {
37  memcpy (save_buf, current_context, sizeof (octave_jmp_buf));
38 }
39 
40 void
42 {
43  memcpy (current_context, save_buf, sizeof (octave_jmp_buf));
44 }
45 
46 void
48 {
49 #if defined (OCTAVE_HAVE_SIG_JUMP)
50  siglongjmp (current_context, 1);
51 #else
52  longjmp (current_context, 1);
53 #endif
54 }
55 
56 /* Allow us to save the signal mask and then restore it to the most
57  recently saved value. This is necessary when using the POSIX
58  signal handling interface on some systems calling longjmp out of
59  the signal handler to get to the top level on an interrupt doesn't
60  restore the original signal mask. Alternatively, we could use
61  sigsetjmp/siglongjmp, but saving and restoring the signal mask
62  ourselves works ok and seems simpler just now. */
63 
64 static sigset_t octave_signal_mask;
65 
66 void
68 {
69  sigprocmask (0, 0, &octave_signal_mask);
70 }
71 
72 void
74 {
75  sigprocmask (SIG_SETMASK, &octave_signal_mask, 0);
76 }
77 
79 
80 sig_atomic_t octave_interrupt_state = 0;
81 
82 sig_atomic_t octave_exception_state = 0;
83 
84 volatile sig_atomic_t octave_signal_caught = 0;