Mercurial > octave
annotate libinterp/corefcn/sighandlers.cc @ 20428:7ac907da9fba
Use error() rather than ::error() unless explicitly required.
* resource-manager.cc (instance_ok), shortcut-manager.cc (instance_ok),
daspk.cc (DASPK_ABORT, DASPK_ABORT2), dasrt.cc (DASRT_ABORT, DASRT_ABORT2),
dassl.cc (DASSL_ABORT, DASSL_ABORT2), debug.cc (instance_ok),
display.cc (instance_ok), dynamic-ld.cc (octave_shlib_list::instance_ok,
octave_dynamic_loader::instance_ok, do_load_oct, do_load_mex), file-io.cc
(fopen_mode_to_ios_mode, do_stream_open, Ffprintf, Fsprintf, Fscanf, Ffscanf,
get_sscanf_data, Fsscanf, do_fread, do_fwrite, Fpopen, Ftempname, convert,
Fumask), graphics.in.h (graphics_toolkit::instance_ok,
gh_manager::instance_ok), load-path.cc (instance_ok),
ls-oct-ascii.cc (save_three_d), lsode.cc (LSODE_ABORT, LSODE_ABORT2),
oct-errno.in.cc (instance_ok), octave-link.cc (connect_link),
pager.cc (octave_pager_stream::instance_ok, octave_diary_stream::instance_ok),
quad.cc (QUAD_ABORT, QUAD_ABORT2),
sighandlers.cc (w32_interrupt_manager::instance_ok,
octave_child_list::instance_ok), symtab.cc (do_update_nest),
symtab.h (instance_ok), syscalls.cc (convert), toplev.h (instance_ok),
txt-eng-ft.cc (instance_ok, set_mode), urlwrite.cc (instance_ok),
__init_fltk__.cc (instance_ok), ov-builtin.cc (do_multi_index_op),
ov-classdef.cc (class_fevalStatic, make_class, octave_classdef::subsasgn,
do_multi_index_op, cdef_object_array::subsref, cdef_object_array::subsasgn,
install_meth, meta_subsref, run_constructor, make_meta_class, get_value,
set_value, check_method), ov-classdef.h (meta_subsref, instance_ok),
ov-fcn-handle.cc (octave_fcn_handle), ov-mex-fcn.cc (do_multi_index_op),
ov-range.h (octave_range), ov-typeinfo.cc (instance_ok),
ov-usr-fcn.cc (subsref, do_multi_index_op), pt-arg-list.cc (Fend,
convert_to_const_vector), pt-cell.cc (rvalue1), pt-colon.cc (append, rvalue1),
pt-eval.cc (visit_simple_for_command, visit_switch_command),
pt-exp.cc (is_logically_true, rvalue), pt-id.cc (eval_undefined_error),
pt-id.h (workspace_error), pt-mat.cc (get_concat_class):
Use error() rather than ::error().
author | Rik <rik@octave.org> |
---|---|
date | Thu, 06 Aug 2015 08:09:01 -0700 |
parents | 4f45eaf83908 |
children | f7084eae3318 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18461
diff
changeset
|
3 Copyright (C) 1993-2015 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 | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
240 | 23 #ifdef HAVE_CONFIG_H |
1230 | 24 #include <config.h> |
1 | 25 #endif |
26 | |
2536 | 27 #include <cstdlib> |
28 | |
3503 | 29 #include <iostream> |
1344 | 30 #include <new> |
31 | |
834 | 32 #include <sys/types.h> |
33 #include <unistd.h> | |
1343 | 34 |
3281 | 35 #include "cmd-edit.h" |
5453 | 36 #include "oct-syscalls.h" |
4153 | 37 #include "quit.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13951
diff
changeset
|
38 #include "singleton-cleanup.h" |
3281 | 39 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
40 #include "debug.h" |
4185 | 41 #include "defun.h" |
1352 | 42 #include "error.h" |
10194 | 43 #include "input.h" |
1373 | 44 #include "load-save.h" |
4294 | 45 #include "oct-map.h" |
2091 | 46 #include "pager.h" |
4185 | 47 #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
|
48 #include "pt-eval.h" |
1 | 49 #include "sighandlers.h" |
4787 | 50 #include "sysdep.h" |
1352 | 51 #include "syswait.h" |
2091 | 52 #include "toplev.h" |
1 | 53 #include "utils.h" |
5794 | 54 #include "variables.h" |
1 | 55 |
56 // Nonzero means we have already printed a message for this series of | |
57 // SIGPIPES. We assume that the writer will eventually give up. | |
58 int pipe_handler_error_count = 0; | |
59 | |
3018 | 60 // TRUE means we can be interrupted. |
61 bool can_interrupt = false; | |
1 | 62 |
4185 | 63 // TRUE means we should try to enter the debugger on SIGINT. |
15595
6e780fb15c14
Make Vdebug_on_interrupt not be static
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
64 bool Vdebug_on_interrupt = false; |
4185 | 65 |
14889
577df411e0c7
rename octave-core file to octave-workspace
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
66 // Allow users to avoid writing octave-workspace for SIGHUP (sent by |
4449 | 67 // closing gnome-terminal, for example). Note that this variable has |
68 // no effect if Vcrash_dumps_octave_core is FALSE. | |
5794 | 69 static bool Vsighup_dumps_octave_core = true; |
4449 | 70 |
71 // Similar to Vsighup_dumps_octave_core, but for SIGTERM signal. | |
5794 | 72 static bool Vsigterm_dumps_octave_core = true; |
4449 | 73 |
5142 | 74 // List of signals we have caught since last call to octave_signal_handler. |
75 static bool octave_signals_caught[NSIG]; | |
76 | |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
77 // Forward declaration. |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
78 static void user_abort (const char *sig_name, int sig_number); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
79 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
80 #if defined (__WIN32__) && ! defined (__CYGWIN__) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
81 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
82 #define WIN32_LEAN_AND_MEAN |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
83 #include <windows.h> |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
84 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
85 class |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
86 w32_interrupt_manager |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
87 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
88 public: |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
89 ~w32_interrupt_manager (void) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
90 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
91 if (thread) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
92 CloseHandle (thread); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
93 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
94 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
95 static bool init (void) { return instance_ok (); } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
96 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
97 static void octave_jump_to_enclosing_context (void) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
98 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
99 if (instance_ok ()) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
100 instance->do_octave_jump_to_enclosing_context (); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
101 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
102 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
103 static void user_abort (const char *sig_name, int sig_number) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
104 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
105 if (instance_ok ()) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
106 instance->do_user_abort (sig_name, sig_number); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
107 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
108 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
109 static void raise_sigint (void) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
110 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
111 if (instance_ok ()) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
112 instance->do_raise_sigint (); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
113 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
114 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
115 private: |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
116 w32_interrupt_manager (void) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
117 : thread (0), thread_id (0) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
118 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
119 thread_id = GetCurrentThreadId (); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
120 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
121 DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
122 GetCurrentProcess (), &thread, 0, FALSE, |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
123 DUPLICATE_SAME_ACCESS); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
124 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
125 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
126 static void octave_jump_to_enclosing_context_sync (void) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
127 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
128 #ifdef _MSC_VER |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
129 _fpreset (); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
130 #endif |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
131 ::octave_jump_to_enclosing_context (); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
132 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
133 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
134 void do_octave_jump_to_enclosing_context (void) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
135 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
136 bool is_interrupt_thread = (GetCurrentThreadId () == thread_id); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
137 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
138 if (is_interrupt_thread) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
139 octave_jump_to_enclosing_context_sync (); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
140 else |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
141 { |
18461
9cfba3616503
allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents:
17958
diff
changeset
|
142 // 64-bit Windows does not appear to have threadContext.Eip. |
9cfba3616503
allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents:
17958
diff
changeset
|
143 // Something else must be done here to allow interrupts to |
9cfba3616503
allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents:
17958
diff
changeset
|
144 // properly work across threads. |
9cfba3616503
allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents:
17958
diff
changeset
|
145 |
9cfba3616503
allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents:
17958
diff
changeset
|
146 #if ! (defined (__MINGW64__) || defined (_WIN64)) |
9cfba3616503
allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents:
17958
diff
changeset
|
147 |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
148 CONTEXT threadContext; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
149 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
150 SuspendThread (thread); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
151 threadContext.ContextFlags = CONTEXT_CONTROL; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
152 GetThreadContext (thread, &threadContext); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
153 threadContext.Eip = (DWORD) octave_jump_to_enclosing_context_sync; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
154 SetThreadContext (thread, &threadContext); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
155 ResumeThread (thread); |
18461
9cfba3616503
allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents:
17958
diff
changeset
|
156 #endif |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
157 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
158 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
159 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
160 void do_user_abort (const char *sig_name, int sig_number) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
161 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
162 bool is_interrupt_thread = (GetCurrentThreadId () == thread_id); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
163 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
164 if (is_interrupt_thread) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
165 ::user_abort (sig_name, sig_number); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
166 else |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
167 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
168 SuspendThread (thread); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
169 ::user_abort (sig_name, sig_number); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
170 ResumeThread (thread); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
171 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
172 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
173 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
174 void do_raise_sigint (void) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
175 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
176 bool is_interrupt_thread = (GetCurrentThreadId () == thread_id); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
177 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
178 if (is_interrupt_thread) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
179 ::raise (SIGINT); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
180 else |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
181 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
182 SuspendThread (thread); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
183 ::raise (SIGINT); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
184 ResumeThread (thread); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
185 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
186 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
187 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
188 static bool instance_ok (void) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
189 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
190 bool retval = true; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
191 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
192 if (! instance) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
193 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
194 instance = new w32_interrupt_manager (); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
195 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
196 if (instance) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
197 singleton_cleanup_list::add (cleanup_instance); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
198 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
199 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
200 if (! instance) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
201 { |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
20172
diff
changeset
|
202 error ("unable to create w32_interrupt_manager"); |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
203 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
204 retval = false; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
205 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
206 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
207 return retval; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
208 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
209 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
210 static void cleanup_instance (void) { delete instance; instance = 0; } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
211 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
212 private: |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
213 // A handle to the thread that is running the octave interpreter. |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
214 HANDLE thread; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
215 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
216 // The ID of the thread that is running the octave interpreter. |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
217 DWORD thread_id; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
218 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
219 static w32_interrupt_manager* instance; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
220 }; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
221 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
222 w32_interrupt_manager* w32_interrupt_manager::instance = 0; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
223 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
224 void w32_raise_sigint (void) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
225 { |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
226 w32_interrupt_manager::raise_sigint (); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
227 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
228 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
229 #endif |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
230 |
11525
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
231 // Signal handler return type. |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
232 #ifndef BADSIG |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
233 #define BADSIG (void (*)(int))-1 |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
234 #endif |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
235 |
14338
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
236 // The following is a workaround for an apparent bug in GCC 4.1.2 and |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
237 // possibly earlier versions. See Octave bug report #30685 for details. |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
238 #if defined (__GNUC__) |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
239 # if ! (__GNUC__ > 4 \ |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
240 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 1 \ |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
241 || (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ > 2)))) |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
242 # undef GNULIB_NAMESPACE |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
243 # define GNULIB_NAMESPACE |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
244 # warning "disabling GNULIB_NAMESPACE for signal functions -- consider upgrading to a current version of GCC" |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
245 # endif |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
246 #endif |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
247 |
11525
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
248 #define BLOCK_SIGNAL(sig, nvar, ovar) \ |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
249 do \ |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
250 { \ |
14338
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
251 GNULIB_NAMESPACE::sigemptyset (&nvar); \ |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
252 GNULIB_NAMESPACE::sigaddset (&nvar, sig); \ |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
253 GNULIB_NAMESPACE::sigemptyset (&ovar); \ |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
254 GNULIB_NAMESPACE::sigprocmask (SIG_BLOCK, &nvar, &ovar); \ |
11525
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
255 } \ |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
256 while (0) |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
257 |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
258 #if !defined (SIGCHLD) && defined (SIGCLD) |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
259 #define SIGCHLD SIGCLD |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
260 #endif |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
261 |
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
262 #define BLOCK_CHILD(nvar, ovar) BLOCK_SIGNAL (SIGCHLD, nvar, ovar) |
14338
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
263 #define UNBLOCK_CHILD(ovar) GNULIB_NAMESPACE::sigprocmask (SIG_SETMASK, &ovar, 0) |
11525
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
264 |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
265 // Called from octave_quit () to actually do something about the signals |
5142 | 266 // we have caught. |
267 | |
268 void | |
269 octave_signal_handler (void) | |
270 { | |
271 // The list of signals is relatively short, so we will just go | |
272 // linearly through the list. | |
273 | |
274 for (int i = 0; i < NSIG; i++) | |
275 { | |
276 if (octave_signals_caught[i]) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
277 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
278 octave_signals_caught[i] = false; |
5142 | 279 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
280 switch (i) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
281 { |
5451 | 282 #ifdef SIGCHLD |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
283 case SIGCHLD: |
11555
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
284 { |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
285 volatile octave_interrupt_handler saved_interrupt_handler |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
286 = octave_ignore_interrupts (); |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
287 |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
288 sigset_t set, oset; |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
289 |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
290 BLOCK_CHILD (set, oset); |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
291 |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
292 octave_child_list::wait (); |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
293 |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
294 octave_set_interrupt_handler (saved_interrupt_handler); |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
295 |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
296 UNBLOCK_CHILD (oset); |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
297 |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
298 octave_child_list::reap (); |
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
299 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
300 break; |
5451 | 301 #endif |
5142 | 302 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
303 case SIGFPE: |
14893 | 304 std::cerr << "warning: floating point exception" << std::endl; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
305 break; |
5142 | 306 |
5451 | 307 #ifdef SIGPIPE |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
308 case SIGPIPE: |
14893 | 309 std::cerr << "warning: broken pipe" << std::endl; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
310 break; |
5451 | 311 #endif |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
312 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
313 } |
5142 | 314 } |
315 } | |
316 | |
1 | 317 static void |
4787 | 318 my_friendly_exit (const char *sig_name, int sig_number, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
319 bool save_vars = true) |
1 | 320 { |
2536 | 321 static bool been_there_done_that = false; |
322 | |
323 if (been_there_done_that) | |
324 { | |
2554 | 325 #if defined (SIGABRT) |
2536 | 326 octave_set_signal_handler (SIGABRT, SIG_DFL); |
327 #endif | |
328 | |
3644 | 329 std::cerr << "panic: attempted clean up apparently failed -- aborting...\n"; |
5451 | 330 |
331 MINGW_SIGNAL_CLEANUP (); | |
332 | |
2536 | 333 abort (); |
334 } | |
335 else | |
336 { | |
337 been_there_done_that = true; | |
1373 | 338 |
3644 | 339 std::cerr << "panic: " << sig_name << " -- stopping myself...\n"; |
2536 | 340 |
4787 | 341 if (save_vars) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
342 dump_octave_core (); |
2536 | 343 |
3162 | 344 if (sig_number < 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
345 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
346 MINGW_SIGNAL_CLEANUP (); |
5451 | 347 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
348 exit (1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
349 } |
3162 | 350 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
351 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
352 octave_set_signal_handler (sig_number, SIG_DFL); |
3162 | 353 |
14338
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
354 GNULIB_NAMESPACE::raise (sig_number); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
355 } |
2536 | 356 } |
1 | 357 } |
358 | |
1446 | 359 sig_handler * |
5770 | 360 octave_set_signal_handler (int sig, sig_handler *handler, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
361 bool restart_syscalls) |
1446 | 362 { |
363 struct sigaction act, oact; | |
5144 | 364 |
1446 | 365 act.sa_handler = handler; |
366 act.sa_flags = 0; | |
5144 | 367 |
10344
65974373505a
Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
368 #if defined (SIGALRM) |
5144 | 369 if (sig == SIGALRM) |
370 { | |
371 #if defined (SA_INTERRUPT) | |
372 act.sa_flags |= SA_INTERRUPT; | |
373 #endif | |
374 } | |
10344
65974373505a
Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
375 #endif |
5144 | 376 #if defined (SA_RESTART) |
10344
65974373505a
Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
377 #if defined (SIGALRM) |
65974373505a
Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
378 else |
65974373505a
Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
379 #endif |
17861
870f3e12e163
maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
380 // FIXME: Do we also need to explicitly disable SA_RESTART? |
10344
65974373505a
Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
381 if (restart_syscalls) |
5770 | 382 act.sa_flags |= SA_RESTART; |
5144 | 383 #endif |
384 | |
14338
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
385 GNULIB_NAMESPACE::sigemptyset (&act.sa_mask); |
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
386 GNULIB_NAMESPACE::sigemptyset (&oact.sa_mask); |
5144 | 387 |
14338
1ecfba4427ff
workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents:
14154
diff
changeset
|
388 GNULIB_NAMESPACE::sigaction (sig, &act, &oact); |
5144 | 389 |
1446 | 390 return oact.sa_handler; |
391 } | |
392 | |
10246 | 393 static void |
1446 | 394 generic_sig_handler (int sig) |
1 | 395 { |
5844 | 396 my_friendly_exit (strsignal (sig), sig); |
1 | 397 } |
398 | |
2091 | 399 // Handle SIGCHLD. |
1230 | 400 |
4064 | 401 #ifdef SIGCHLD |
10246 | 402 static void |
2092 | 403 sigchld_handler (int /* sig */) |
1230 | 404 { |
11555
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
405 octave_signal_caught = 1; |
2626 | 406 |
11555
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
407 octave_signals_caught[SIGCHLD] = true; |
1230 | 408 } |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14443
diff
changeset
|
409 #endif /* defined (SIGCHLD) */ |
1230 | 410 |
4064 | 411 #ifdef SIGFPE |
1373 | 412 #if defined (__alpha__) |
10246 | 413 static void |
1488 | 414 sigfpe_handler (int /* sig */) |
1373 | 415 { |
5142 | 416 if (can_interrupt && octave_interrupt_state >= 0) |
417 { | |
418 octave_signal_caught = 1; | |
1373 | 419 |
5142 | 420 octave_signals_caught[SIGFPE] = true; |
4182 | 421 |
5142 | 422 octave_interrupt_state++; |
423 } | |
1373 | 424 } |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14443
diff
changeset
|
425 #endif /* defined (__alpha__) */ |
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14443
diff
changeset
|
426 #endif /* defined (SIGFPE) */ |
1373 | 427 |
4449 | 428 #if defined (SIGHUP) || defined (SIGTERM) |
10246 | 429 static void |
4449 | 430 sig_hup_or_term_handler (int sig) |
431 { | |
432 switch (sig) | |
433 { | |
434 #if defined (SIGHUP) | |
435 case SIGHUP: | |
436 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
437 if (Vsighup_dumps_octave_core) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
438 dump_octave_core (); |
4449 | 439 } |
440 break; | |
441 #endif | |
442 | |
443 #if defined (SIGTERM) | |
444 case SIGTERM: | |
445 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
446 if (Vsigterm_dumps_octave_core) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
447 dump_octave_core (); |
4449 | 448 } |
449 break; | |
450 #endif | |
451 | |
452 default: | |
453 break; | |
454 } | |
455 | |
456 clean_up_and_exit (0); | |
457 } | |
458 #endif | |
459 | |
3343 | 460 #if 0 |
3281 | 461 #if defined (SIGWINCH) |
10246 | 462 static void |
3281 | 463 sigwinch_handler (int /* sig */) |
464 { | |
465 command_editor::resize_terminal (); | |
466 } | |
467 #endif | |
3343 | 468 #endif |
3281 | 469 |
635 | 470 // Handle SIGINT by restarting the parser (see octave.cc). |
2554 | 471 // |
472 // This also has to work for SIGBREAK (on systems that have it), so we | |
473 // use the value of sig, instead of just assuming that it is called | |
474 // for SIGINT only. | |
635 | 475 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
476 static void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
477 user_abort (const char *sig_name, int sig_number) |
1 | 478 { |
4172 | 479 if (! octave_initialized) |
480 exit (1); | |
481 | |
1 | 482 if (can_interrupt) |
483 { | |
4185 | 484 if (Vdebug_on_interrupt) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
485 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
486 if (! octave_debug_on_interrupt_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
487 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
488 tree_evaluator::debug_mode = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
489 octave_debug_on_interrupt_state = true; |
4185 | 490 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
491 return; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
492 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
493 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
494 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
495 // Clear the flag and do normal interrupt stuff. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
496 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
497 tree_evaluator::debug_mode |
10194 | 498 = bp_table::have_breakpoints () || Vdebugging; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
499 octave_debug_on_interrupt_state = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
500 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
501 } |
4185 | 502 |
4153 | 503 if (octave_interrupt_immediately) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
504 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
505 if (octave_interrupt_state == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
506 octave_interrupt_state = 1; |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
507 |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
508 #if defined (__WIN32__) && ! defined (__CYGWIN__) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
509 w32_interrupt_manager::octave_jump_to_enclosing_context (); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
510 #else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
511 octave_jump_to_enclosing_context (); |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
512 #endif |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
513 } |
4429 | 514 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
515 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
516 // If we are already cleaning up from a previous interrupt, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
517 // take note of the fact that another interrupt signal has |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
518 // arrived. |
4793 | 519 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
520 if (octave_interrupt_state < 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
521 octave_interrupt_state = 0; |
4793 | 522 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
523 octave_signal_caught = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
524 octave_interrupt_state++; |
4787 | 525 |
19849
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
526 if (interactive && ! forced_interactive |
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
527 && octave_interrupt_state == 2) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
528 std::cerr << "Press Control-C again to abort." << std::endl; |
4787 | 529 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
530 if (octave_interrupt_state >= 3) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
531 my_friendly_exit (sig_name, sig_number, true); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
532 } |
1 | 533 } |
534 | |
5451 | 535 } |
536 | |
10246 | 537 static void |
5451 | 538 sigint_handler (int sig) |
539 { | |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
540 #if defined (__WIN32__) && ! defined (__CYGWIN__) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
541 w32_interrupt_manager::user_abort (strsignal (sig), sig); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
542 #else |
5844 | 543 user_abort (strsignal (sig), sig); |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
544 #endif |
1 | 545 } |
546 | |
4064 | 547 #ifdef SIGPIPE |
10246 | 548 static void |
1488 | 549 sigpipe_handler (int /* sig */) |
1 | 550 { |
5142 | 551 octave_signal_caught = 1; |
552 | |
553 octave_signals_caught[SIGPIPE] = true; | |
1 | 554 |
1358 | 555 // Don't loop forever on account of this. |
556 | |
5142 | 557 if (pipe_handler_error_count++ > 100 && octave_interrupt_state >= 0) |
4787 | 558 octave_interrupt_state++; |
1 | 559 } |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14443
diff
changeset
|
560 #endif /* defined (SIGPIPE) */ |
1 | 561 |
2705 | 562 octave_interrupt_handler |
2554 | 563 octave_catch_interrupts (void) |
564 { | |
2705 | 565 octave_interrupt_handler retval; |
2554 | 566 |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
567 #if defined (__WIN32__) && ! defined (__CYGWIN__) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
568 w32_interrupt_manager::init (); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
569 #endif |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
570 |
2554 | 571 #ifdef SIGINT |
2705 | 572 retval.int_handler = octave_set_signal_handler (SIGINT, sigint_handler); |
2554 | 573 #endif |
574 | |
575 #ifdef SIGBREAK | |
2705 | 576 retval.brk_handler = octave_set_signal_handler (SIGBREAK, sigint_handler); |
2554 | 577 #endif |
2705 | 578 |
579 return retval; | |
2554 | 580 } |
581 | |
2705 | 582 octave_interrupt_handler |
583 octave_ignore_interrupts (void) | |
2554 | 584 { |
2705 | 585 octave_interrupt_handler retval; |
586 | |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
587 #if defined (__WIN32__) && ! defined (__CYGWIN__) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
588 w32_interrupt_manager::init (); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
589 #endif |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
590 |
2554 | 591 #ifdef SIGINT |
2705 | 592 retval.int_handler = octave_set_signal_handler (SIGINT, SIG_IGN); |
2554 | 593 #endif |
594 | |
595 #ifdef SIGBREAK | |
2705 | 596 retval.brk_handler = octave_set_signal_handler (SIGBREAK, SIG_IGN); |
2554 | 597 #endif |
2705 | 598 |
599 return retval; | |
600 } | |
601 | |
602 octave_interrupt_handler | |
5770 | 603 octave_set_interrupt_handler (const volatile octave_interrupt_handler& h, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
604 bool restart_syscalls) |
2705 | 605 { |
606 octave_interrupt_handler retval; | |
607 | |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
608 #if defined (__WIN32__) && ! defined (__CYGWIN__) |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
609 w32_interrupt_manager::init (); |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
610 #endif |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
611 |
2705 | 612 #ifdef SIGINT |
5770 | 613 retval.int_handler = octave_set_signal_handler (SIGINT, h.int_handler, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
614 restart_syscalls); |
2705 | 615 #endif |
616 | |
617 #ifdef SIGBREAK | |
5770 | 618 retval.brk_handler = octave_set_signal_handler (SIGBREAK, h.brk_handler, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
619 restart_syscalls); |
2705 | 620 #endif |
621 | |
622 return retval; | |
1651 | 623 } |
624 | |
635 | 625 // Install all the handlers for the signals we might care about. |
626 | |
1 | 627 void |
628 install_signal_handlers (void) | |
629 { | |
5142 | 630 for (int i = 0; i < NSIG; i++) |
631 octave_signals_caught[i] = false; | |
632 | |
2554 | 633 octave_catch_interrupts (); |
634 | |
1 | 635 #ifdef SIGABRT |
1446 | 636 octave_set_signal_handler (SIGABRT, generic_sig_handler); |
1 | 637 #endif |
638 | |
639 #ifdef SIGALRM | |
1446 | 640 octave_set_signal_handler (SIGALRM, generic_sig_handler); |
1 | 641 #endif |
642 | |
643 #ifdef SIGBUS | |
1446 | 644 octave_set_signal_handler (SIGBUS, generic_sig_handler); |
1 | 645 #endif |
646 | |
1230 | 647 #ifdef SIGCHLD |
1446 | 648 octave_set_signal_handler (SIGCHLD, sigchld_handler); |
1230 | 649 #endif |
650 | |
3174 | 651 // SIGCLD |
652 // SIGCONT | |
653 | |
1 | 654 #ifdef SIGEMT |
1446 | 655 octave_set_signal_handler (SIGEMT, generic_sig_handler); |
1 | 656 #endif |
657 | |
658 #ifdef SIGFPE | |
1373 | 659 #if defined (__alpha__) |
1446 | 660 octave_set_signal_handler (SIGFPE, sigfpe_handler); |
1373 | 661 #else |
1446 | 662 octave_set_signal_handler (SIGFPE, generic_sig_handler); |
1 | 663 #endif |
1373 | 664 #endif |
1 | 665 |
666 #ifdef SIGHUP | |
4449 | 667 octave_set_signal_handler (SIGHUP, sig_hup_or_term_handler); |
1 | 668 #endif |
669 | |
670 #ifdef SIGILL | |
1446 | 671 octave_set_signal_handler (SIGILL, generic_sig_handler); |
1 | 672 #endif |
673 | |
3174 | 674 // SIGINFO |
675 // SIGINT | |
676 | |
1 | 677 #ifdef SIGIOT |
1446 | 678 octave_set_signal_handler (SIGIOT, generic_sig_handler); |
1 | 679 #endif |
680 | |
681 #ifdef SIGLOST | |
1446 | 682 octave_set_signal_handler (SIGLOST, generic_sig_handler); |
1 | 683 #endif |
684 | |
685 #ifdef SIGPIPE | |
1446 | 686 octave_set_signal_handler (SIGPIPE, sigpipe_handler); |
1 | 687 #endif |
688 | |
689 #ifdef SIGPOLL | |
1446 | 690 octave_set_signal_handler (SIGPOLL, SIG_IGN); |
1 | 691 #endif |
692 | |
5866 | 693 // SIGPROF |
3174 | 694 // SIGPWR |
695 | |
1 | 696 #ifdef SIGQUIT |
1446 | 697 octave_set_signal_handler (SIGQUIT, generic_sig_handler); |
1 | 698 #endif |
699 | |
700 #ifdef SIGSEGV | |
1446 | 701 octave_set_signal_handler (SIGSEGV, generic_sig_handler); |
1 | 702 #endif |
703 | |
3174 | 704 // SIGSTOP |
705 | |
1 | 706 #ifdef SIGSYS |
1446 | 707 octave_set_signal_handler (SIGSYS, generic_sig_handler); |
1 | 708 #endif |
709 | |
710 #ifdef SIGTERM | |
4449 | 711 octave_set_signal_handler (SIGTERM, sig_hup_or_term_handler); |
1 | 712 #endif |
713 | |
714 #ifdef SIGTRAP | |
1446 | 715 octave_set_signal_handler (SIGTRAP, generic_sig_handler); |
1 | 716 #endif |
717 | |
3174 | 718 // SIGTSTP |
719 // SIGTTIN | |
720 // SIGTTOU | |
721 // SIGURG | |
722 | |
1 | 723 #ifdef SIGUSR1 |
1446 | 724 octave_set_signal_handler (SIGUSR1, generic_sig_handler); |
1 | 725 #endif |
726 | |
727 #ifdef SIGUSR2 | |
1446 | 728 octave_set_signal_handler (SIGUSR2, generic_sig_handler); |
1 | 729 #endif |
730 | |
731 #ifdef SIGVTALRM | |
1446 | 732 octave_set_signal_handler (SIGVTALRM, generic_sig_handler); |
1 | 733 #endif |
734 | |
895 | 735 #ifdef SIGIO |
1446 | 736 octave_set_signal_handler (SIGIO, SIG_IGN); |
895 | 737 #endif |
738 | |
3343 | 739 #if 0 |
3281 | 740 #ifdef SIGWINCH |
741 octave_set_signal_handler (SIGWINCH, sigwinch_handler); | |
742 #endif | |
3343 | 743 #endif |
3174 | 744 |
1 | 745 #ifdef SIGXCPU |
1446 | 746 octave_set_signal_handler (SIGXCPU, generic_sig_handler); |
1 | 747 #endif |
748 | |
749 #ifdef SIGXFSZ | |
1446 | 750 octave_set_signal_handler (SIGXFSZ, generic_sig_handler); |
1 | 751 #endif |
5451 | 752 |
1 | 753 } |
754 | |
11066
e678346a47d9
toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
755 static octave_scalar_map |
4294 | 756 make_sig_struct (void) |
757 { | |
11066
e678346a47d9
toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
758 octave_scalar_map m; |
4294 | 759 |
760 #ifdef SIGABRT | |
4675 | 761 m.assign ("ABRT", SIGABRT); |
4294 | 762 #endif |
763 | |
764 #ifdef SIGALRM | |
4675 | 765 m.assign ("ALRM", SIGALRM); |
4294 | 766 #endif |
767 | |
768 #ifdef SIGBUS | |
4675 | 769 m.assign ("BUS", SIGBUS); |
4294 | 770 #endif |
771 | |
772 #ifdef SIGCHLD | |
4675 | 773 m.assign ("CHLD", SIGCHLD); |
4294 | 774 #endif |
775 | |
776 #ifdef SIGCLD | |
4675 | 777 m.assign ("CLD", SIGCLD); |
4294 | 778 #endif |
779 | |
780 #ifdef SIGCONT | |
4675 | 781 m.assign ("CONT", SIGCONT); |
4294 | 782 #endif |
783 | |
784 #ifdef SIGEMT | |
4675 | 785 m.assign ("EMT", SIGEMT); |
4294 | 786 #endif |
787 | |
788 #ifdef SIGFPE | |
4675 | 789 m.assign ("FPE", SIGFPE); |
4294 | 790 #endif |
791 | |
792 #ifdef SIGHUP | |
4675 | 793 m.assign ("HUP", SIGHUP); |
4294 | 794 #endif |
795 | |
796 #ifdef SIGILL | |
4675 | 797 m.assign ("ILL", SIGILL); |
4294 | 798 #endif |
799 | |
800 #ifdef SIGINFO | |
4675 | 801 m.assign ("INFO", SIGINFO); |
4294 | 802 #endif |
803 | |
804 #ifdef SIGINT | |
4675 | 805 m.assign ("INT", SIGINT); |
4294 | 806 #endif |
807 | |
16706
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
808 #ifdef SIGIO |
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
809 m.assign ("IO", SIGIO); |
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
810 #endif |
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
811 |
4294 | 812 #ifdef SIGIOT |
4675 | 813 m.assign ("IOT", SIGIOT); |
4294 | 814 #endif |
815 | |
16706
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
816 #ifdef SIGKILL |
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
817 m.assign ("KILL", SIGKILL); |
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
818 #endif |
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
819 |
4294 | 820 #ifdef SIGLOST |
4675 | 821 m.assign ("LOST", SIGLOST); |
4294 | 822 #endif |
823 | |
824 #ifdef SIGPIPE | |
4675 | 825 m.assign ("PIPE", SIGPIPE); |
4294 | 826 #endif |
827 | |
828 #ifdef SIGPOLL | |
4675 | 829 m.assign ("POLL", SIGPOLL); |
4294 | 830 #endif |
831 | |
832 #ifdef SIGPROF | |
4675 | 833 m.assign ("PROF", SIGPROF); |
4294 | 834 #endif |
835 | |
836 #ifdef SIGPWR | |
4675 | 837 m.assign ("PWR", SIGPWR); |
4294 | 838 #endif |
839 | |
840 #ifdef SIGQUIT | |
4675 | 841 m.assign ("QUIT", SIGQUIT); |
4294 | 842 #endif |
843 | |
844 #ifdef SIGSEGV | |
4675 | 845 m.assign ("SEGV", SIGSEGV); |
4294 | 846 #endif |
847 | |
16706
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
848 #ifdef SIGSTKFLT |
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
849 m.assign ("STKFLT", SIGSTKFLT); |
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
850 #endif |
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
851 |
4294 | 852 #ifdef SIGSTOP |
4675 | 853 m.assign ("STOP", SIGSTOP); |
4294 | 854 #endif |
855 | |
856 #ifdef SIGSYS | |
4675 | 857 m.assign ("SYS", SIGSYS); |
4294 | 858 #endif |
859 | |
860 #ifdef SIGTERM | |
4675 | 861 m.assign ("TERM", SIGTERM); |
4294 | 862 #endif |
863 | |
864 #ifdef SIGTRAP | |
4675 | 865 m.assign ("TRAP", SIGTRAP); |
4294 | 866 #endif |
867 | |
868 #ifdef SIGTSTP | |
4675 | 869 m.assign ("TSTP", SIGTSTP); |
4294 | 870 #endif |
871 | |
872 #ifdef SIGTTIN | |
4675 | 873 m.assign ("TTIN", SIGTTIN); |
4294 | 874 #endif |
875 | |
876 #ifdef SIGTTOU | |
4675 | 877 m.assign ("TTOU", SIGTTOU); |
4294 | 878 #endif |
879 | |
16706
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
880 #ifdef SIGUNUSED |
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
881 m.assign ("UNUSED", SIGUNUSED); |
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
882 #endif |
736dca8371ee
include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16404
diff
changeset
|
883 |
4294 | 884 #ifdef SIGURG |
4675 | 885 m.assign ("URG", SIGURG); |
4294 | 886 #endif |
887 | |
888 #ifdef SIGUSR1 | |
4675 | 889 m.assign ("USR1", SIGUSR1); |
4294 | 890 #endif |
891 | |
892 #ifdef SIGUSR2 | |
4675 | 893 m.assign ("USR2", SIGUSR2); |
4294 | 894 #endif |
895 | |
896 #ifdef SIGVTALRM | |
4675 | 897 m.assign ("VTALRM", SIGVTALRM); |
4294 | 898 #endif |
899 | |
900 #ifdef SIGWINCH | |
4675 | 901 m.assign ("WINCH", SIGWINCH); |
4294 | 902 #endif |
903 | |
904 #ifdef SIGXCPU | |
4675 | 905 m.assign ("XCPU", SIGXCPU); |
4294 | 906 #endif |
907 | |
908 #ifdef SIGXFSZ | |
4675 | 909 m.assign ("XFSZ", SIGXFSZ); |
4294 | 910 #endif |
911 | |
912 return m; | |
913 } | |
914 | |
5142 | 915 octave_child_list::octave_child_list_rep *octave_child_list::instance = 0; |
5128 | 916 |
2926 | 917 bool |
918 octave_child_list::instance_ok (void) | |
919 { | |
920 bool retval = true; | |
921 | |
922 if (! instance) | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13951
diff
changeset
|
923 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13951
diff
changeset
|
924 instance = new octave_child_list_rep (); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13951
diff
changeset
|
925 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13951
diff
changeset
|
926 if (instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13951
diff
changeset
|
927 singleton_cleanup_list::add (cleanup_instance); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13951
diff
changeset
|
928 } |
2926 | 929 |
930 if (! instance) | |
931 { | |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
20172
diff
changeset
|
932 error ("unable to create child list object!"); |
2926 | 933 |
934 retval = false; | |
935 } | |
936 | |
937 return retval; | |
938 } | |
939 | |
940 void | |
5142 | 941 octave_child_list::insert (pid_t pid, octave_child::child_event_handler f) |
942 { | |
943 if (instance_ok ()) | |
944 instance->insert (pid, f); | |
945 } | |
946 | |
947 void | |
948 octave_child_list::reap (void) | |
2926 | 949 { |
950 if (instance_ok ()) | |
5142 | 951 instance->reap (); |
952 } | |
953 | |
954 bool | |
955 octave_child_list::wait (void) | |
956 { | |
957 return (instance_ok ()) ? instance->wait () : false; | |
2926 | 958 } |
959 | |
5142 | 960 class pid_equal |
961 { | |
962 public: | |
963 | |
964 pid_equal (pid_t v) : val (v) { } | |
965 | |
966 bool operator () (const octave_child& oc) const { return oc.pid == val; } | |
967 | |
968 private: | |
969 | |
970 pid_t val; | |
971 }; | |
972 | |
2926 | 973 void |
974 octave_child_list::remove (pid_t pid) | |
975 { | |
976 if (instance_ok ()) | |
5142 | 977 instance->remove_if (pid_equal (pid)); |
2926 | 978 } |
979 | |
5142 | 980 #define OCL_REP octave_child_list::octave_child_list_rep |
2926 | 981 |
5142 | 982 void |
983 OCL_REP::insert (pid_t pid, octave_child::child_event_handler f) | |
2926 | 984 { |
5142 | 985 append (octave_child (pid, f)); |
2926 | 986 } |
987 | |
2209 | 988 void |
5142 | 989 OCL_REP::reap (void) |
2209 | 990 { |
5142 | 991 // Mark the record for PID invalid. |
2209 | 992 |
5142 | 993 for (iterator p = begin (); p != end (); p++) |
994 { | |
995 // The call to the octave_child::child_event_handler might | |
996 // invalidate the iterator (for example, by calling | |
997 // octave_child_list::remove), so we increment the iterator | |
998 // here. | |
2209 | 999 |
5142 | 1000 octave_child& oc = *p; |
2209 | 1001 |
5142 | 1002 if (oc.have_status) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1003 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1004 oc.have_status = 0; |
5142 | 1005 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1006 octave_child::child_event_handler f = oc.handler; |
5142 | 1007 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1008 if (f && f (oc.pid, oc.status)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1009 oc.pid = -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1010 } |
2209 | 1011 } |
1012 | |
5142 | 1013 remove_if (pid_equal (-1)); |
2209 | 1014 } |
1015 | |
5142 | 1016 // Wait on our children and record any changes in their status. |
1017 | |
1018 bool | |
1019 OCL_REP::wait (void) | |
2210 | 1020 { |
5142 | 1021 bool retval = false; |
2210 | 1022 |
5142 | 1023 for (iterator p = begin (); p != end (); p++) |
2210 | 1024 { |
5142 | 1025 octave_child& oc = *p; |
1026 | |
1027 pid_t pid = oc.pid; | |
1028 | |
1029 if (pid > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1030 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1031 int status; |
2210 | 1032 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1033 if (octave_syscalls::waitpid (pid, &status, WNOHANG) > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1034 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1035 oc.have_status = 1; |
5142 | 1036 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1037 oc.status = status; |
5142 | 1038 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1039 retval = true; |
5142 | 1040 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1041 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1042 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
1043 } |
2210 | 1044 } |
1045 | |
5142 | 1046 return retval; |
2210 | 1047 } |
1048 | |
5780 | 1049 DEFUN (SIG, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
1050 "-*- texinfo -*-\n\ |
5780 | 1051 @deftypefn {Built-in Function} {} SIG ()\n\ |
1052 Return a structure containing Unix signal names and their defined values.\n\ | |
1053 @end deftypefn") | |
1054 { | |
1055 octave_value retval; | |
1056 | |
1057 if (args.length () == 0) | |
1058 { | |
11066
e678346a47d9
toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1059 static octave_scalar_map m = make_sig_struct (); |
5780 | 1060 |
1061 retval = m; | |
1062 } | |
1063 else | |
5823 | 1064 print_usage (); |
5780 | 1065 |
1066 return retval; | |
1067 } | |
1068 | |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1069 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
1070 %!assert (isstruct (SIG ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
1071 %!assert (! isempty (SIG ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
1072 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
1073 %!error SIG (1) |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1074 */ |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1075 |
5794 | 1076 DEFUN (debug_on_interrupt, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
1077 "-*- texinfo -*-\n\ |
10840 | 1078 @deftypefn {Built-in Function} {@var{val} =} debug_on_interrupt ()\n\ |
5794 | 1079 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_interrupt (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12832
diff
changeset
|
1080 @deftypefnx {Built-in Function} {} debug_on_interrupt (@var{new_val}, \"local\")\n\ |
5794 | 1081 Query or set the internal variable that controls whether Octave will try\n\ |
1082 to enter debugging mode when it receives an interrupt signal (typically\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1083 generated with @kbd{C-c}).\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1084 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1085 If a second interrupt signal is received before reaching the debugging mode,\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1086 a normal interrupt will occur.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12832
diff
changeset
|
1087 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
1088 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1089 variable is changed locally for the function and any subroutines it calls.\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
1090 The original variable value is restored when exiting the function.\n\ |
15573
63d024333bee
doc: Add seealso links between debug_on_XXX functions (bug #37576)
Rik <rik@octave.org>
parents:
14338
diff
changeset
|
1091 @seealso{debug_on_error, debug_on_warning}\n\ |
5794 | 1092 @end deftypefn") |
4449 | 1093 { |
5794 | 1094 return SET_INTERNAL_VARIABLE (debug_on_interrupt); |
4449 | 1095 } |
1096 | |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1097 /* |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1098 %!test |
12832 | 1099 %! orig_val = debug_on_interrupt (); |
1100 %! old_val = debug_on_interrupt (! orig_val); | |
1101 %! assert (orig_val, old_val); | |
1102 %! assert (debug_on_interrupt (), ! orig_val); | |
1103 %! debug_on_interrupt (orig_val); | |
1104 %! 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
|
1105 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
1106 %!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
|
1107 */ |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1108 |
5794 | 1109 DEFUN (sighup_dumps_octave_core, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
1110 "-*- texinfo -*-\n\ |
10840 | 1111 @deftypefn {Built-in Function} {@var{val} =} sighup_dumps_octave_core ()\n\ |
5794 | 1112 @deftypefnx {Built-in Function} {@var{old_val} =} sighup_dumps_octave_core (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12832
diff
changeset
|
1113 @deftypefnx {Built-in Function} {} sighup_dumps_octave_core (@var{new_val}, \"local\")\n\ |
5794 | 1114 Query or set the internal variable that controls whether Octave tries\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
1115 to save all current variables to the file @file{octave-workspace} if it\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
1116 receives a hangup signal.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12832
diff
changeset
|
1117 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
1118 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1119 variable is changed locally for the function and any subroutines it calls.\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
1120 The original variable value is restored when exiting the function.\n\ |
5794 | 1121 @end deftypefn") |
4185 | 1122 { |
5794 | 1123 return SET_INTERNAL_VARIABLE (sighup_dumps_octave_core); |
1124 } | |
4294 | 1125 |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1126 /* |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1127 %!test |
12832 | 1128 %! orig_val = sighup_dumps_octave_core (); |
1129 %! old_val = sighup_dumps_octave_core (! orig_val); | |
1130 %! assert (orig_val, old_val); | |
1131 %! assert (sighup_dumps_octave_core (), ! orig_val); | |
1132 %! sighup_dumps_octave_core (orig_val); | |
1133 %! 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
|
1134 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
1135 %!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
|
1136 */ |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1137 |
5794 | 1138 DEFUN (sigterm_dumps_octave_core, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
1139 "-*- texinfo -*-\n\ |
10840 | 1140 @deftypefn {Built-in Function} {@var{val} =} sigterm_dumps_octave_core ()\n\ |
5794 | 1141 @deftypefnx {Built-in Function} {@var{old_val} =} sigterm_dumps_octave_core (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12832
diff
changeset
|
1142 @deftypefnx {Built-in Function} {} sigterm_dumps_octave_core (@var{new_val}, \"local\")\n\ |
5794 | 1143 Query or set the internal variable that controls whether Octave tries\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
1144 to save all current variables to the file @file{octave-workspace} if it\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
1145 receives a terminate signal.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12832
diff
changeset
|
1146 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
1147 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1148 variable is changed locally for the function and any subroutines it calls.\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
1149 The original variable value is restored when exiting the function.\n\ |
5794 | 1150 @end deftypefn") |
1151 { | |
1152 return SET_INTERNAL_VARIABLE (sigterm_dumps_octave_core); | |
4185 | 1153 } |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1154 |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1155 /* |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1156 %!test |
12832 | 1157 %! orig_val = sigterm_dumps_octave_core (); |
1158 %! old_val = sigterm_dumps_octave_core (! orig_val); | |
1159 %! assert (orig_val, old_val); | |
1160 %! assert (sigterm_dumps_octave_core (), ! orig_val); | |
1161 %! sigterm_dumps_octave_core (orig_val); | |
1162 %! 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
|
1163 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
1164 %!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
|
1165 */ |