Mercurial > octave
annotate libinterp/corefcn/sighandlers.cc @ 23084:ef4d915df748
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 23 Jan 2017 14:27:48 -0500 |
parents | f75d289645ec e9a0469dedd9 |
children | b7a24a734c37 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
22196
diff
changeset
|
3 Copyright (C) 1993-2016 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
1 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
1 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21609
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
24 # include "config.h" |
1 | 25 #endif |
26 | |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
27 #include <csignal> |
2536 | 28 #include <cstdlib> |
29 | |
3503 | 30 #include <iostream> |
1344 | 31 #include <new> |
32 | |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
33 #if defined (OCTAVE_USE_WINDOWS_API) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
34 # define WIN32_LEAN_AND_MEAN |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
35 # include <windows.h> |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
36 #endif |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
37 |
3281 | 38 #include "cmd-edit.h" |
5453 | 39 #include "oct-syscalls.h" |
4153 | 40 #include "quit.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13951
diff
changeset
|
41 #include "singleton-cleanup.h" |
21938
da9b960b1b2d
use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
21936
diff
changeset
|
42 #include "signal-wrappers.h" |
3281 | 43 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
44 #include "debug.h" |
4185 | 45 #include "defun.h" |
1352 | 46 #include "error.h" |
10194 | 47 #include "input.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
48 #include "interpreter.h" |
1373 | 49 #include "load-save.h" |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
50 #include "octave.h" |
4294 | 51 #include "oct-map.h" |
2091 | 52 #include "pager.h" |
4185 | 53 #include "pt-bp.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
54 #include "pt-eval.h" |
1 | 55 #include "sighandlers.h" |
4787 | 56 #include "sysdep.h" |
1 | 57 #include "utils.h" |
5794 | 58 #include "variables.h" |
1 | 59 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
60 namespace octave |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
61 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
62 // Nonzero means we have already printed a message for this series of |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
63 // SIGPIPES. We assume that the writer will eventually give up. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
64 int pipe_handler_error_count = 0; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
65 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
66 // TRUE means we can be interrupted. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
67 bool can_interrupt = false; |
1 | 68 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
69 // TRUE means we should try to enter the debugger on SIGINT. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
70 bool Vdebug_on_interrupt = false; |
1 | 71 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
72 // Allow users to avoid writing octave-workspace for SIGHUP (sent by |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
73 // closing gnome-terminal, for example). Note that this variable has |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
74 // no effect if Vcrash_dumps_octave_core is FALSE. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
75 static bool Vsighup_dumps_octave_core = true; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
76 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
77 // Similar to Vsighup_dumps_octave_core, but for SIGTERM signal. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
78 static bool Vsigterm_dumps_octave_core = true; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
79 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
80 // List of signals we have caught since last call to octave::signal_handler. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
81 static bool *signals_caught = 0; |
4185 | 82 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
83 // Forward declaration. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
84 static void user_abort (const char *sig_name, int sig_number); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
85 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
86 class |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
87 base_interrupt_manager |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
88 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
89 public: |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
90 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
91 base_interrupt_manager (void) { } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
92 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
93 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
94 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
95 base_interrupt_manager (const base_interrupt_manager&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
96 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
97 base_interrupt_manager& operator = (const base_interrupt_manager&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
98 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
99 virtual ~base_interrupt_manager (void) = default; |
4449 | 100 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
101 virtual void do_jump_to_enclosing_context (void) = 0; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
102 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
103 virtual void do_user_abort (const char *sig_name, int sig_number) = 0; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
104 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
105 virtual void do_raise_sigint (void) = 0; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
106 }; |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
107 |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
108 #if defined (OCTAVE_USE_WINDOWS_API) |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
109 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
110 class |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
111 w32_interrupt_manager : public base_interrupt_manager |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
112 { |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
113 public: |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
114 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
115 w32_interrupt_manager (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
116 : thread (0), thread_id (0) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
117 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
118 thread_id = GetCurrentThreadId (); |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
119 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
120 DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
121 GetCurrentProcess (), &thread, 0, FALSE, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
122 DUPLICATE_SAME_ACCESS); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
123 } |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
124 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
125 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
126 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
127 w32_interrupt_manager (const w32_interrupt_manager&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
128 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
129 w32_interrupt_manager& operator = (const w32_interrupt_manager&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
130 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
131 ~w32_interrupt_manager (void) = default; |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
132 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
133 static void jump_to_enclosing_context_sync (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
134 { |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21609
diff
changeset
|
135 #if defined (_MSC_VER) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
136 _fpreset (); |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
137 #endif |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
138 ::octave_jump_to_enclosing_context (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
139 } |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
140 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
141 void do_jump_to_enclosing_context (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
142 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
143 bool is_interrupt_thread = (GetCurrentThreadId () == thread_id); |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
144 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
145 if (is_interrupt_thread) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
146 jump_to_enclosing_context_sync (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
147 else |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
148 { |
18461
9cfba3616503
allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents:
17958
diff
changeset
|
149 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
150 CONTEXT threadContext; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
151 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
152 SuspendThread (thread); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
153 threadContext.ContextFlags = CONTEXT_CONTROL; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
154 GetThreadContext (thread, &threadContext); |
22382 | 155 |
156 #if (defined (__MINGW64__) || defined (_WIN64)) | |
157 threadContext.Rip = (DWORD64) jump_to_enclosing_context_sync; | |
158 #else | |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
159 threadContext.Eip = (DWORD) jump_to_enclosing_context_sync; |
22382 | 160 #endif |
161 | |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
162 SetThreadContext (thread, &threadContext); |
22382 | 163 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
164 ResumeThread (thread); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
165 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
166 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
167 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
168 void do_user_abort (const char *sig_name, int sig_number) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
169 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
170 bool is_interrupt_thread = (GetCurrentThreadId () == thread_id); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
171 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
172 if (is_interrupt_thread) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
173 octave::user_abort (sig_name, sig_number); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
174 else |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
175 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
176 SuspendThread (thread); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
177 octave::user_abort (sig_name, sig_number); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
178 ResumeThread (thread); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
179 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
180 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
181 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
182 void do_raise_sigint (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
183 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
184 bool is_interrupt_thread = (GetCurrentThreadId () == thread_id); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
185 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
186 if (is_interrupt_thread) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
187 octave_raise_wrapper (SIGINT); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
188 else |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
189 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
190 SuspendThread (thread); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
191 octave_raise_wrapper (SIGINT); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
192 ResumeThread (thread); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
193 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
194 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
195 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
196 private: |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
197 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
198 // A handle to the thread that is running the octave interpreter. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
199 HANDLE thread; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
200 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
201 // The ID of the thread that is running the octave interpreter. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
202 DWORD thread_id; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
203 }; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
204 |
18461
9cfba3616503
allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents:
17958
diff
changeset
|
205 #endif |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
206 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
207 class |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
208 posix_interrupt_manager : public base_interrupt_manager |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
209 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
210 public: |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
211 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
212 posix_interrupt_manager (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
213 : base_interrupt_manager () |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
214 { } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
215 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
216 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
217 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
218 posix_interrupt_manager (const posix_interrupt_manager&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
219 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
220 posix_interrupt_manager& |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
221 operator = (const posix_interrupt_manager&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
222 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
223 ~posix_interrupt_manager (void) = default; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
224 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
225 void do_jump_to_enclosing_context (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
226 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
227 ::octave_jump_to_enclosing_context (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
228 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
229 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
230 void do_user_abort (const char *sig_name, int sig_number) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
231 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
232 octave::user_abort (sig_name, sig_number); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
233 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
234 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
235 void do_raise_sigint (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
236 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
237 octave_raise_wrapper (SIGINT); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
238 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
239 }; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
240 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
241 class |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
242 interrupt_manager |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
243 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
244 public: |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
245 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
246 ~interrupt_manager (void) = default; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
247 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
248 static bool init (void) { return instance_ok (); } |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
249 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
250 static void jump_to_enclosing_context (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
251 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
252 if (instance_ok ()) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
253 instance->do_jump_to_enclosing_context (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
254 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
255 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
256 static void user_abort (const char *sig_name, int sig_number) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
257 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
258 if (instance_ok ()) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
259 instance->do_user_abort (sig_name, sig_number); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
260 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
261 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
262 static void raise_sigint (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
263 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
264 if (instance_ok ()) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
265 instance->do_raise_sigint (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
266 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
267 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
268 private: |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
269 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
270 interrupt_manager (void) { } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
271 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
272 // No copying! |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
273 |
22865
89756f2f085b
use c++11 style for deleting default copy constructor and assignment operator
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
274 interrupt_manager (const interrupt_manager&) = delete; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
275 |
22865
89756f2f085b
use c++11 style for deleting default copy constructor and assignment operator
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
276 interrupt_manager& operator = (const interrupt_manager&) = delete; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
277 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
278 static bool instance_ok (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
279 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
280 bool retval = true; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
281 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
282 if (! instance) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
283 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
284 instance = create_instance (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
285 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
286 if (instance) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
287 singleton_cleanup_list::add (cleanup_instance); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
288 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
289 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
290 if (! instance) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
291 error ("unable to create interrupt_manager"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
292 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
293 return retval; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
294 } |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
295 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
296 static base_interrupt_manager *create_instance (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
297 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
298 #if defined (OCTAVE_USE_WINDOWS_API) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
299 return new w32_interrupt_manager (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
300 #else |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
301 return new posix_interrupt_manager (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
302 #endif |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
303 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
304 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
305 static void cleanup_instance (void) { delete instance; instance = 0; } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
306 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
307 static base_interrupt_manager* instance; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
308 }; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
309 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
310 base_interrupt_manager *interrupt_manager::instance = 0; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
311 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
312 // Called from octave_quit () to actually do something about the signals |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
313 // we have caught. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
314 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
315 void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
316 signal_handler (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
317 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
318 // The list of signals is relatively short, so we will just go |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
319 // linearly through the list. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
320 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
321 static int sigchld; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
322 static int sigfpe; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
323 static int sigpipe; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
324 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
325 static const bool have_sigchld = octave_get_sig_number ("SIGCHLD", &sigchld); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
326 static const bool have_sigfpe = octave_get_sig_number ("SIGFPE", &sigfpe); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
327 static const bool have_sigpipe = octave_get_sig_number ("SIGPIPE", &sigpipe); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
328 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
329 for (int i = 0; i < octave_num_signals (); i++) |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
330 { |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
331 if (signals_caught[i]) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
332 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
333 signals_caught[i] = false; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
334 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
335 if (have_sigchld && i == sigchld) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
336 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
337 volatile interrupt_handler saved_interrupt_handler |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
338 = ignore_interrupts (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
339 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
340 void *context = octave_block_child (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
341 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
342 child_list::wait (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
343 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
344 set_interrupt_handler (saved_interrupt_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
345 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
346 octave_unblock_child (context); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
347 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
348 child_list::reap (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
349 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
350 else if (have_sigfpe && i == sigfpe) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
351 std::cerr << "warning: floating point exception" << std::endl; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
352 else if (have_sigpipe && i == sigpipe) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
353 std::cerr << "warning: broken pipe" << std::endl; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
354 } |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
355 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
356 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
357 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
358 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
359 my_friendly_exit (const char *sig_name, int sig_number, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
360 bool save_vars = true) |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
361 { |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
362 static bool been_there_done_that = false; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
363 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
364 if (been_there_done_that) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
365 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
366 set_signal_handler ("SIGABRT", SIG_DFL); |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
367 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
368 std::cerr << "panic: attempted clean up failed -- aborting..." |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
369 << std::endl; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
370 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
371 sysdep_cleanup (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
372 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
373 abort (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
374 } |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
375 else |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
376 { |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
377 been_there_done_that = true; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
378 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
379 std::cerr << "panic: " << sig_name << " -- stopping myself..." |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
380 << std::endl; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
381 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
382 if (save_vars) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
383 dump_octave_core (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
384 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
385 if (sig_number < 0) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
386 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
387 sysdep_cleanup (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
388 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
389 exit (1); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
390 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
391 else |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
392 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
393 set_signal_handler (sig_number, SIG_DFL); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
394 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
395 octave_raise_wrapper (sig_number); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
396 } |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
397 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
398 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
399 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
400 sig_handler * |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
401 set_signal_handler (int sig, sig_handler *handler, bool restart_syscalls) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
402 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
403 return octave_set_signal_handler_internal (sig, handler, restart_syscalls); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
404 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
405 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
406 sig_handler * |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
407 set_signal_handler (const char *signame, sig_handler *handler, |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22382
diff
changeset
|
408 bool restart_syscalls) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
409 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
410 return octave_set_signal_handler_by_name (signame, handler, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
411 restart_syscalls); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
412 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
413 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
414 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
415 generic_sig_handler (int sig) |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
416 { |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
417 my_friendly_exit (octave_strsignal_wrapper (sig), sig); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
418 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
419 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
420 // Handle SIGCHLD. |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
421 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
422 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
423 sigchld_handler (int sig) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
424 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
425 octave_signal_caught = 1; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
426 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
427 signals_caught[sig] = true; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
428 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
429 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
430 #if defined (__alpha__) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
431 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
432 sigfpe_handler (int sig) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
433 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
434 if (can_interrupt && octave_interrupt_state >= 0) |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
435 { |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
436 octave_signal_caught = 1; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
437 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
438 signals_caught[sig] = true; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
439 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
440 octave_interrupt_state++; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
441 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
442 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
443 #endif |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
444 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
445 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
446 sig_hup_handler (int /* sig */) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
447 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
448 if (Vsighup_dumps_octave_core) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
449 dump_octave_core (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
450 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
451 clean_up_and_exit (0); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
452 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
453 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
454 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
455 sig_term_handler (int /* sig */) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
456 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
457 if (Vsigterm_dumps_octave_core) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
458 dump_octave_core (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
459 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
460 clean_up_and_exit (0); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
461 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
462 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
463 #if 0 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
464 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
465 sigwinch_handler (int /* sig */) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
466 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
467 command_editor::resize_terminal (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
468 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
469 #endif |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
470 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
471 // Handle SIGINT by restarting the parser (see octave.cc). |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
472 // |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
473 // This also has to work for SIGBREAK (on systems that have it), so we |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
474 // use the value of sig, instead of just assuming that it is called |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
475 // for SIGINT only. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
476 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
477 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
478 user_abort (const char *sig_name, int sig_number) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
479 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
480 if (! octave_initialized) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
481 exit (1); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
482 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
483 if (can_interrupt) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
484 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
485 if (Vdebug_on_interrupt) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
486 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
487 if (! octave_debug_on_interrupt_state) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
488 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
489 octave::tree_evaluator::debug_mode = true; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
490 octave_debug_on_interrupt_state = true; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
491 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
492 return; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
493 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
494 else |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
495 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
496 // Clear the flag and do normal interrupt stuff. |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
497 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
498 octave::tree_evaluator::debug_mode |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
499 = bp_table::have_breakpoints () || Vdebugging; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
500 octave_debug_on_interrupt_state = false; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
501 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
502 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
503 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
504 if (octave_interrupt_immediately) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
505 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
506 if (octave_interrupt_state == 0) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
507 octave_interrupt_state = 1; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
508 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
509 interrupt_manager::jump_to_enclosing_context (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
510 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
511 else |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
512 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
513 // If we are already cleaning up from a previous interrupt, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
514 // take note of the fact that another interrupt signal has |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
515 // arrived. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
516 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
517 if (octave_interrupt_state < 0) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
518 octave_interrupt_state = 0; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
519 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
520 octave_signal_caught = 1; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
521 octave_interrupt_state++; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
522 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
523 if (octave::application::interactive () |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
524 && ! octave::application::forced_interactive () |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
525 && octave_interrupt_state == 2) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
526 std::cerr << "Press Control-C again to abort." << std::endl; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
527 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
528 if (octave_interrupt_state >= 3) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
529 my_friendly_exit (sig_name, sig_number, true); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
530 } |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
531 } |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
532 } |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
533 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
534 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
535 sigint_handler (int sig) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
536 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
537 interrupt_manager::user_abort (octave_strsignal_wrapper (sig), sig); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
538 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
539 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
540 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
541 sigpipe_handler (int sig) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
542 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
543 octave_signal_caught = 1; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
544 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
545 signals_caught[sig] = true; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
546 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
547 // Don't loop forever on account of this. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
548 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
549 if (pipe_handler_error_count++ > 100 && octave_interrupt_state >= 0) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
550 octave_interrupt_state++; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
551 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
552 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
553 interrupt_handler |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
554 catch_interrupts (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
555 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
556 interrupt_handler retval; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
557 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
558 interrupt_manager::init (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
559 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
560 retval.int_handler = set_signal_handler ("SIGINT", sigint_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
561 retval.brk_handler = set_signal_handler ("SIGBREAK", sigint_handler); |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
562 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
563 return retval; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
564 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
565 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
566 interrupt_handler |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
567 ignore_interrupts (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
568 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
569 interrupt_handler retval; |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
570 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
571 interrupt_manager::init (); |
5142 | 572 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
573 retval.int_handler = set_signal_handler ("SIGINT", SIG_IGN); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
574 retval.brk_handler = set_signal_handler ("SIGBREAK", SIG_IGN); |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
575 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
576 return retval; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
577 } |
11555
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
578 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
579 interrupt_handler |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
580 set_interrupt_handler (const volatile interrupt_handler& h, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
581 bool restart_syscalls) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
582 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
583 interrupt_handler retval; |
5142 | 584 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
585 interrupt_manager::init (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
586 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
587 retval.int_handler = set_signal_handler ("SIGINT", h.int_handler, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
588 restart_syscalls); |
5142 | 589 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
590 retval.brk_handler = set_signal_handler ("SIGBREAK", h.brk_handler, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
591 restart_syscalls); |
2536 | 592 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
593 return retval; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
594 } |
5451 | 595 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
596 // Install all the handlers for the signals we might care about. |
1373 | 597 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
598 void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
599 install_signal_handlers (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
600 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
601 if (! signals_caught) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
602 signals_caught = new bool [octave_num_signals ()]; |
5451 | 603 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
604 for (int i = 0; i < octave_num_signals (); i++) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
605 signals_caught[i] = false; |
3162 | 606 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
607 catch_interrupts (); |
5144 | 608 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
609 set_signal_handler ("SIGABRT", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
610 set_signal_handler ("SIGALRM", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
611 set_signal_handler ("SIGBUS", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
612 set_signal_handler ("SIGCHLD", sigchld_handler); |
1446 | 613 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
614 // SIGCLD |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
615 // SIGCONT |
1230 | 616 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
617 set_signal_handler ("SIGEMT", generic_sig_handler); |
1230 | 618 |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
619 #if defined (__alpha__) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
620 set_signal_handler ("SIGFPE", sigfpe_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
621 #else |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
622 set_signal_handler ("SIGFPE", generic_sig_handler); |
3281 | 623 #endif |
624 | |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
625 set_signal_handler ("SIGHUP", sig_hup_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
626 set_signal_handler ("SIGILL", generic_sig_handler); |
4172 | 627 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
628 // SIGINFO |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
629 // SIGINT |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
630 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
631 set_signal_handler ("SIGIOT", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
632 set_signal_handler ("SIGLOST", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
633 set_signal_handler ("SIGPIPE", sigpipe_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
634 set_signal_handler ("SIGPOLL", SIG_IGN); |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
635 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
636 // SIGPROF |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
637 // SIGPWR |
4793 | 638 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
639 set_signal_handler ("SIGQUIT", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
640 set_signal_handler ("SIGSEGV", generic_sig_handler); |
4787 | 641 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
642 // SIGSTOP |
5451 | 643 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
644 set_signal_handler ("SIGSYS", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
645 set_signal_handler ("SIGTERM", sig_term_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
646 set_signal_handler ("SIGTRAP", generic_sig_handler); |
1 | 647 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
648 // SIGTSTP |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
649 // SIGTTIN |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
650 // SIGTTOU |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
651 // SIGURG |
2554 | 652 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
653 set_signal_handler ("SIGUSR1", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
654 set_signal_handler ("SIGUSR2", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
655 set_signal_handler ("SIGVTALRM", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
656 set_signal_handler ("SIGIO", SIG_IGN); |
2705 | 657 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
658 #if 0 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
659 set_signal_handler ("SIGWINCH", sigwinch_handler); |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
660 #endif |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
661 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
662 set_signal_handler ("SIGXCPU", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
663 set_signal_handler ("SIGXFSZ", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
664 } |
635 | 665 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
666 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
667 set_sig_struct_field (octave_scalar_map& m, const char *signame) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
668 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
669 int signum; |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
670 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
671 // The names in the struct do not include the leading "SIG" prefix. |
1 | 672 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
673 if (octave_get_sig_number (signame, &signum)) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
674 m.assign (&signame[3], signum); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
675 } |
3174 | 676 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
677 static octave_scalar_map |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
678 make_sig_struct (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
679 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
680 octave_scalar_map m; |
3174 | 681 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
682 set_sig_struct_field (m, "SIGABRT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
683 set_sig_struct_field (m, "SIGALRM"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
684 set_sig_struct_field (m, "SIGBUS"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
685 set_sig_struct_field (m, "SIGCHLD"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
686 set_sig_struct_field (m, "SIGCLD"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
687 set_sig_struct_field (m, "SIGCONT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
688 set_sig_struct_field (m, "SIGEMT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
689 set_sig_struct_field (m, "SIGFPE"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
690 set_sig_struct_field (m, "SIGHUP"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
691 set_sig_struct_field (m, "SIGILL"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
692 set_sig_struct_field (m, "SIGINFO"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
693 set_sig_struct_field (m, "SIGINT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
694 set_sig_struct_field (m, "SIGIO"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
695 set_sig_struct_field (m, "SIGIOT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
696 set_sig_struct_field (m, "SIGKILL"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
697 set_sig_struct_field (m, "SIGLOST"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
698 set_sig_struct_field (m, "SIGPIPE"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
699 set_sig_struct_field (m, "SIGPOLL"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
700 set_sig_struct_field (m, "SIGPROF"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
701 set_sig_struct_field (m, "SIGPWR"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
702 set_sig_struct_field (m, "SIGQUIT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
703 set_sig_struct_field (m, "SIGSEGV"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
704 set_sig_struct_field (m, "SIGSTKFLT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
705 set_sig_struct_field (m, "SIGSTOP"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
706 set_sig_struct_field (m, "SIGSYS"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
707 set_sig_struct_field (m, "SIGTERM"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
708 set_sig_struct_field (m, "SIGTRAP"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
709 set_sig_struct_field (m, "SIGTSTP"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
710 set_sig_struct_field (m, "SIGTTIN"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
711 set_sig_struct_field (m, "SIGTTOU"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
712 set_sig_struct_field (m, "SIGUNUSED"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
713 set_sig_struct_field (m, "SIGURG"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
714 set_sig_struct_field (m, "SIGUSR1"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
715 set_sig_struct_field (m, "SIGUSR2"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
716 set_sig_struct_field (m, "SIGVTALRM"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
717 set_sig_struct_field (m, "SIGWINCH"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
718 set_sig_struct_field (m, "SIGXCPU"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
719 set_sig_struct_field (m, "SIGXFSZ"); |
4294 | 720 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
721 return m; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
722 } |
4294 | 723 } |
724 | |
5780 | 725 DEFUN (SIG, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
726 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
727 @deftypefn {} {} SIG () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
728 Return a structure containing Unix signal names and their defined values. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
729 @end deftypefn */) |
5780 | 730 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
731 if (args.length () != 0) |
5823 | 732 print_usage (); |
5780 | 733 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
734 static octave_scalar_map m = octave::make_sig_struct (); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
735 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
736 return ovl (m); |
5780 | 737 } |
738 | |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
739 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
740 %!assert (isstruct (SIG ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
741 %!assert (! isempty (SIG ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
742 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
743 %!error SIG (1) |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
744 */ |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
745 |
5794 | 746 DEFUN (debug_on_interrupt, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
747 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
748 @deftypefn {} {@var{val} =} debug_on_interrupt () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
749 @deftypefnx {} {@var{old_val} =} debug_on_interrupt (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
750 @deftypefnx {} {} debug_on_interrupt (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
751 Query or set the internal variable that controls whether Octave will try |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
752 to enter debugging mode when it receives an interrupt signal (typically |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
753 generated with @kbd{C-c}). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
754 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
755 If a second interrupt signal is received before reaching the debugging mode, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
756 a normal interrupt will occur. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
757 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
758 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
759 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
760 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
761 @seealso{debug_on_error, debug_on_warning} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
762 @end deftypefn */) |
4449 | 763 { |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
764 return set_internal_variable (octave::Vdebug_on_interrupt, args, nargout, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
765 "debug_on_interrupt"); |
4449 | 766 } |
767 | |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
768 /* |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
769 %!test |
12832 | 770 %! orig_val = debug_on_interrupt (); |
771 %! old_val = debug_on_interrupt (! orig_val); | |
772 %! assert (orig_val, old_val); | |
773 %! assert (debug_on_interrupt (), ! orig_val); | |
774 %! debug_on_interrupt (orig_val); | |
775 %! assert (debug_on_interrupt (), orig_val); | |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
776 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
777 %!error (debug_on_interrupt (1, 2)) |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
778 */ |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
779 |
5794 | 780 DEFUN (sighup_dumps_octave_core, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
781 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
782 @deftypefn {} {@var{val} =} sighup_dumps_octave_core () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
783 @deftypefnx {} {@var{old_val} =} sighup_dumps_octave_core (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
784 @deftypefnx {} {} sighup_dumps_octave_core (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
785 Query or set the internal variable that controls whether Octave tries |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
786 to save all current variables to the file @file{octave-workspace} if it |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
787 receives a hangup signal. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
788 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
789 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
790 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
791 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
792 @end deftypefn */) |
4185 | 793 { |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
794 return set_internal_variable (octave::Vsighup_dumps_octave_core, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
795 args, nargout, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
796 "sighup_dumps_octave_core"); |
5794 | 797 } |
4294 | 798 |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
799 /* |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
800 %!test |
12832 | 801 %! orig_val = sighup_dumps_octave_core (); |
802 %! old_val = sighup_dumps_octave_core (! orig_val); | |
803 %! assert (orig_val, old_val); | |
804 %! assert (sighup_dumps_octave_core (), ! orig_val); | |
805 %! sighup_dumps_octave_core (orig_val); | |
806 %! assert (sighup_dumps_octave_core (), orig_val); | |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
807 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
808 %!error (sighup_dumps_octave_core (1, 2)) |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
809 */ |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
810 |
5794 | 811 DEFUN (sigterm_dumps_octave_core, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
812 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
813 @deftypefn {} {@var{val} =} sigterm_dumps_octave_core () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
814 @deftypefnx {} {@var{old_val} =} sigterm_dumps_octave_core (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
815 @deftypefnx {} {} sigterm_dumps_octave_core (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
816 Query or set the internal variable that controls whether Octave tries |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
817 to save all current variables to the file @file{octave-workspace} if it |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
818 receives a terminate signal. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
819 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
820 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
821 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
822 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
823 @end deftypefn */) |
5794 | 824 { |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
825 return set_internal_variable (octave::Vsigterm_dumps_octave_core, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
826 args, nargout, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
827 "sigterm_dumps_octave_core"); |
4185 | 828 } |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
829 |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
830 /* |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
831 %!test |
12832 | 832 %! orig_val = sigterm_dumps_octave_core (); |
833 %! old_val = sigterm_dumps_octave_core (! orig_val); | |
834 %! assert (orig_val, old_val); | |
835 %! assert (sigterm_dumps_octave_core (), ! orig_val); | |
836 %! sigterm_dumps_octave_core (orig_val); | |
837 %! assert (sigterm_dumps_octave_core (), orig_val); | |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
838 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
839 %!error (sigterm_dumps_octave_core (1, 2)) |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
840 */ |