Mercurial > octave
annotate src/sighandlers.cc @ 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
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 30 Sep 2010 06:00:00 -0400 |
parents | 89f4d7e294cc |
children | 2f29b765c0ef |
rev | line source |
---|---|
1 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, |
8920 | 4 2003, 2004, 2005, 2006, 2007, 2008, 2009 John W. Eaton |
1 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1 | 21 |
22 */ | |
23 | |
240 | 24 #ifdef HAVE_CONFIG_H |
1230 | 25 #include <config.h> |
1 | 26 #endif |
27 | |
2536 | 28 #include <cstdlib> |
29 | |
3503 | 30 #include <iostream> |
1344 | 31 #include <new> |
32 | |
834 | 33 #include <sys/types.h> |
34 #include <unistd.h> | |
1343 | 35 |
3281 | 36 #include "cmd-edit.h" |
5453 | 37 #include "oct-syscalls.h" |
4153 | 38 #include "quit.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. |
64 static bool Vdebug_on_interrupt = false; | |
65 | |
4449 | 66 // Allow users to avoid writing octave-core for SIGHUP (sent by |
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 |
2554 | 74 #if defined (__EMX__) |
2626 | 75 #define MAYBE_ACK_SIGNAL(sig) \ |
2554 | 76 octave_set_signal_handler (sig, SIG_ACK) |
2931 | 77 #define ACK_USES_SIG 1 |
2554 | 78 #else |
2626 | 79 #define MAYBE_ACK_SIGNAL(sig) \ |
2554 | 80 do { } while (0) |
81 #endif | |
82 | |
5142 | 83 // List of signals we have caught since last call to octave_signal_handler. |
84 static bool octave_signals_caught[NSIG]; | |
85 | |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
86 // Called from octave_quit () to actually do something about the signals |
5142 | 87 // we have caught. |
88 | |
89 void | |
90 octave_signal_handler (void) | |
91 { | |
92 // The list of signals is relatively short, so we will just go | |
93 // linearly through the list. | |
94 | |
95 for (int i = 0; i < NSIG; i++) | |
96 { | |
97 if (octave_signals_caught[i]) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
98 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
99 octave_signals_caught[i] = false; |
5142 | 100 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
101 switch (i) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
102 { |
5451 | 103 #ifdef SIGCHLD |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
104 case SIGCHLD: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
105 octave_child_list::reap (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
106 break; |
5451 | 107 #endif |
5142 | 108 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
109 case SIGFPE: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
110 std::cerr << "warning: floating point exception -- trying to return to prompt" << std::endl; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
111 break; |
5142 | 112 |
5451 | 113 #ifdef SIGPIPE |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
114 case SIGPIPE: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
115 std::cerr << "warning: broken pipe -- some output may be lost" << std::endl; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
116 break; |
5451 | 117 #endif |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
118 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
119 } |
5142 | 120 } |
121 } | |
122 | |
1 | 123 static void |
4787 | 124 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
|
125 bool save_vars = true) |
1 | 126 { |
2536 | 127 static bool been_there_done_that = false; |
128 | |
129 if (been_there_done_that) | |
130 { | |
2554 | 131 #if defined (SIGABRT) |
2536 | 132 octave_set_signal_handler (SIGABRT, SIG_DFL); |
133 #endif | |
134 | |
3644 | 135 std::cerr << "panic: attempted clean up apparently failed -- aborting...\n"; |
5451 | 136 |
137 MINGW_SIGNAL_CLEANUP (); | |
138 | |
2536 | 139 abort (); |
140 } | |
141 else | |
142 { | |
143 been_there_done_that = true; | |
1373 | 144 |
3644 | 145 std::cerr << "panic: " << sig_name << " -- stopping myself...\n"; |
2536 | 146 |
4787 | 147 if (save_vars) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
148 dump_octave_core (); |
2536 | 149 |
3162 | 150 if (sig_number < 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
151 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
152 MINGW_SIGNAL_CLEANUP (); |
5451 | 153 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
154 exit (1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
155 } |
3162 | 156 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
157 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
158 octave_set_signal_handler (sig_number, SIG_DFL); |
3162 | 159 |
4092 | 160 #if defined (HAVE_RAISE) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
161 raise (sig_number); |
4092 | 162 #elif defined (HAVE_KILL) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
163 kill (getpid (), sig_number); |
4092 | 164 #else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
165 exit (1); |
4092 | 166 #endif |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
167 } |
4092 | 168 |
2536 | 169 } |
1 | 170 } |
171 | |
1446 | 172 sig_handler * |
5770 | 173 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
|
174 bool restart_syscalls) |
1446 | 175 { |
176 struct sigaction act, oact; | |
5144 | 177 |
1446 | 178 act.sa_handler = handler; |
179 act.sa_flags = 0; | |
5144 | 180 |
10344
65974373505a
Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
181 #if defined (SIGALRM) |
5144 | 182 if (sig == SIGALRM) |
183 { | |
184 #if defined (SA_INTERRUPT) | |
185 act.sa_flags |= SA_INTERRUPT; | |
186 #endif | |
187 } | |
10344
65974373505a
Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
188 #endif |
5144 | 189 #if defined (SA_RESTART) |
10344
65974373505a
Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
190 #if defined (SIGALRM) |
65974373505a
Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
191 else |
65974373505a
Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
192 #endif |
5775 | 193 // 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
|
194 if (restart_syscalls) |
5770 | 195 act.sa_flags |= SA_RESTART; |
5144 | 196 #endif |
197 | |
10411 | 198 gnulib::sigemptyset (&act.sa_mask); |
199 gnulib::sigemptyset (&oact.sa_mask); | |
5144 | 200 |
10411 | 201 gnulib::sigaction (sig, &act, &oact); |
5144 | 202 |
1446 | 203 return oact.sa_handler; |
204 } | |
205 | |
10246 | 206 static void |
1446 | 207 generic_sig_handler (int sig) |
1 | 208 { |
5844 | 209 my_friendly_exit (strsignal (sig), sig); |
1 | 210 } |
211 | |
2091 | 212 // Handle SIGCHLD. |
1230 | 213 |
4064 | 214 #ifdef SIGCHLD |
10246 | 215 static void |
2092 | 216 sigchld_handler (int /* sig */) |
1230 | 217 { |
2705 | 218 volatile octave_interrupt_handler saved_interrupt_handler |
2554 | 219 = octave_ignore_interrupts (); |
220 | |
2626 | 221 // I wonder if this is really right, or if SIGCHLD should just be |
222 // blocked on OS/2 systems the same as for systems with POSIX signal | |
223 // functions. | |
224 | |
225 #if defined (__EMX__) | |
2554 | 226 volatile sig_handler *saved_sigchld_handler |
2626 | 227 = octave_set_signal_handler (SIGCHLD, SIG_IGN); |
2554 | 228 #endif |
229 | |
2626 | 230 sigset_t set, oset; |
231 | |
232 BLOCK_CHILD (set, oset); | |
233 | |
5142 | 234 if (octave_child_list::wait ()) |
2554 | 235 { |
5142 | 236 // The status of some child changed. |
2209 | 237 |
5142 | 238 octave_signal_caught = 1; |
2197 | 239 |
5142 | 240 octave_signals_caught[SIGCHLD] = true; |
1230 | 241 } |
2469 | 242 |
2600 | 243 octave_set_interrupt_handler (saved_interrupt_handler); |
2554 | 244 |
2626 | 245 UNBLOCK_CHILD (oset); |
246 | |
247 #ifdef __EMX__ | |
2554 | 248 octave_set_signal_handler (SIGCHLD, saved_sigchld_handler); |
2475 | 249 #endif |
250 | |
2626 | 251 MAYBE_ACK_SIGNAL (SIGCHLD); |
1230 | 252 } |
4064 | 253 #endif /* defined(SIGCHLD) */ |
1230 | 254 |
4064 | 255 #ifdef SIGFPE |
1373 | 256 #if defined (__alpha__) |
10246 | 257 static void |
1488 | 258 sigfpe_handler (int /* sig */) |
1373 | 259 { |
2626 | 260 MAYBE_ACK_SIGNAL (SIGFPE); |
2554 | 261 |
5142 | 262 if (can_interrupt && octave_interrupt_state >= 0) |
263 { | |
264 octave_signal_caught = 1; | |
1373 | 265 |
5142 | 266 octave_signals_caught[SIGFPE] = true; |
4182 | 267 |
5142 | 268 octave_interrupt_state++; |
269 } | |
1373 | 270 } |
4064 | 271 #endif /* defined(__alpha__) */ |
272 #endif /* defined(SIGFPE) */ | |
1373 | 273 |
4449 | 274 #if defined (SIGHUP) || defined (SIGTERM) |
10246 | 275 static void |
4449 | 276 sig_hup_or_term_handler (int sig) |
277 { | |
278 MAYBE_ACK_SIGNAL (sig); | |
279 | |
280 switch (sig) | |
281 { | |
282 #if defined (SIGHUP) | |
283 case SIGHUP: | |
284 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
285 if (Vsighup_dumps_octave_core) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
286 dump_octave_core (); |
4449 | 287 } |
288 break; | |
289 #endif | |
290 | |
291 #if defined (SIGTERM) | |
292 case SIGTERM: | |
293 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
294 if (Vsigterm_dumps_octave_core) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
295 dump_octave_core (); |
4449 | 296 } |
297 break; | |
298 #endif | |
299 | |
300 default: | |
301 break; | |
302 } | |
303 | |
304 clean_up_and_exit (0); | |
305 } | |
306 #endif | |
307 | |
3343 | 308 #if 0 |
3281 | 309 #if defined (SIGWINCH) |
10246 | 310 static void |
3281 | 311 sigwinch_handler (int /* sig */) |
312 { | |
313 MAYBE_ACK_SIGNAL (SIGWINCH); | |
314 | |
315 command_editor::resize_terminal (); | |
316 } | |
317 #endif | |
3343 | 318 #endif |
3281 | 319 |
635 | 320 // Handle SIGINT by restarting the parser (see octave.cc). |
2554 | 321 // |
322 // This also has to work for SIGBREAK (on systems that have it), so we | |
323 // use the value of sig, instead of just assuming that it is called | |
324 // for SIGINT only. | |
635 | 325 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
326 static void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
327 user_abort (const char *sig_name, int sig_number) |
1 | 328 { |
4172 | 329 if (! octave_initialized) |
330 exit (1); | |
331 | |
1 | 332 if (can_interrupt) |
333 { | |
4185 | 334 if (Vdebug_on_interrupt) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
335 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
336 if (! octave_debug_on_interrupt_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
337 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
338 tree_evaluator::debug_mode = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
339 octave_debug_on_interrupt_state = true; |
4185 | 340 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
341 return; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
342 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
343 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
344 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
345 // 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
|
346 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
347 tree_evaluator::debug_mode |
10194 | 348 = bp_table::have_breakpoints () || Vdebugging; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
349 octave_debug_on_interrupt_state = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
350 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
351 } |
4185 | 352 |
4153 | 353 if (octave_interrupt_immediately) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
354 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
355 if (octave_interrupt_state == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
356 octave_interrupt_state = 1; |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
357 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
358 octave_jump_to_enclosing_context (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
359 } |
4429 | 360 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
361 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
362 // 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
|
363 // 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
|
364 // arrived. |
4793 | 365 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
366 if (octave_interrupt_state < 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
367 octave_interrupt_state = 0; |
4793 | 368 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
369 octave_signal_caught = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
370 octave_interrupt_state++; |
4787 | 371 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
372 if (interactive && octave_interrupt_state == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
373 std::cerr << "Press Control-C again to abort." << std::endl; |
4787 | 374 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
375 if (octave_interrupt_state >= 3) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
376 my_friendly_exit (sig_name, sig_number, true); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
377 } |
1 | 378 } |
379 | |
5451 | 380 } |
381 | |
10246 | 382 static void |
5451 | 383 sigint_handler (int sig) |
384 { | |
385 MAYBE_ACK_SIGNAL (sig); | |
386 | |
387 #ifdef USE_W32_SIGINT | |
388 if (w32_in_main_thread ()) | |
5844 | 389 user_abort (strsignal (sig), sig); |
5451 | 390 else |
391 w32_raise (sig); | |
392 #else | |
5844 | 393 user_abort (strsignal (sig), sig); |
5451 | 394 #endif |
1 | 395 } |
396 | |
4064 | 397 #ifdef SIGPIPE |
10246 | 398 static void |
1488 | 399 sigpipe_handler (int /* sig */) |
1 | 400 { |
2626 | 401 MAYBE_ACK_SIGNAL (SIGPIPE); |
2554 | 402 |
5142 | 403 octave_signal_caught = 1; |
404 | |
405 octave_signals_caught[SIGPIPE] = true; | |
1 | 406 |
1358 | 407 // Don't loop forever on account of this. |
408 | |
5142 | 409 if (pipe_handler_error_count++ > 100 && octave_interrupt_state >= 0) |
4787 | 410 octave_interrupt_state++; |
1 | 411 } |
4064 | 412 #endif /* defined(SIGPIPE) */ |
1 | 413 |
5451 | 414 #ifdef USE_W32_SIGINT |
415 static BOOL CALLBACK | |
416 w32_sigint_handler (DWORD sig) | |
417 { | |
418 const char *sig_name; | |
419 | |
420 switch(sig) | |
421 { | |
422 case CTRL_BREAK_EVENT: | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
423 sig_name = "Ctrl-Break"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
424 break; |
5451 | 425 case CTRL_C_EVENT: |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
426 sig_name = "Ctrl-C"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
427 break; |
5451 | 428 case CTRL_CLOSE_EVENT: |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
429 sig_name = "close console"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
430 break; |
5451 | 431 case CTRL_LOGOFF_EVENT: |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
432 sig_name = "logoff"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
433 break; |
5451 | 434 case CTRL_SHUTDOWN_EVENT: |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
435 sig_name = "shutdown"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
436 break; |
5451 | 437 default: |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
438 sig_name = "unknown console event"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
439 break; |
5451 | 440 } |
441 | |
442 switch(sig) | |
443 { | |
444 case CTRL_BREAK_EVENT: | |
445 case CTRL_C_EVENT: | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
446 w32_raise (SIGINT); |
5451 | 447 break; |
448 | |
449 case CTRL_CLOSE_EVENT: | |
450 case CTRL_LOGOFF_EVENT: | |
451 case CTRL_SHUTDOWN_EVENT: | |
452 default: | |
453 // We should do the following: | |
454 // clean_up_and_exit (0); | |
455 // We can't because we aren't running in the normal Octave thread. | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
456 user_abort(sig_name, sig); |
5451 | 457 break; |
458 } | |
459 | |
460 // Return TRUE if the event was handled, or FALSE if another handler | |
461 // should be called. | |
5775 | 462 // FIXME check that windows terminates the thread. |
5451 | 463 return TRUE; |
464 } | |
465 #endif /* w32_sigint_handler */ | |
466 | |
467 | |
2705 | 468 octave_interrupt_handler |
2554 | 469 octave_catch_interrupts (void) |
470 { | |
2705 | 471 octave_interrupt_handler retval; |
2554 | 472 |
473 #ifdef SIGINT | |
2705 | 474 retval.int_handler = octave_set_signal_handler (SIGINT, sigint_handler); |
2554 | 475 #endif |
476 | |
477 #ifdef SIGBREAK | |
2705 | 478 retval.brk_handler = octave_set_signal_handler (SIGBREAK, sigint_handler); |
2554 | 479 #endif |
2705 | 480 |
5451 | 481 #ifdef USE_W32_SIGINT |
482 | |
483 // Intercept windows console control events. | |
484 // Note that the windows console signal handlers chain, so if | |
485 // install_signal_handlers is called more than once in the same program, | |
486 // then first call the following to avoid duplicates: | |
487 // | |
488 // SetConsoleCtrlHandler (w32_sigint_handler, FALSE); | |
489 | |
490 if (! SetConsoleCtrlHandler (w32_sigint_handler, TRUE)) | |
491 error ("SetConsoleCtrlHandler failed with %ld\n", GetLastError ()); | |
492 | |
493 w32_set_quiet_shutdown (); | |
494 | |
495 #endif | |
496 | |
2705 | 497 return retval; |
2554 | 498 } |
499 | |
2705 | 500 octave_interrupt_handler |
501 octave_ignore_interrupts (void) | |
2554 | 502 { |
2705 | 503 octave_interrupt_handler retval; |
504 | |
2554 | 505 #ifdef SIGINT |
2705 | 506 retval.int_handler = octave_set_signal_handler (SIGINT, SIG_IGN); |
2554 | 507 #endif |
508 | |
509 #ifdef SIGBREAK | |
2705 | 510 retval.brk_handler = octave_set_signal_handler (SIGBREAK, SIG_IGN); |
2554 | 511 #endif |
2705 | 512 |
513 return retval; | |
514 } | |
515 | |
516 octave_interrupt_handler | |
5770 | 517 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
|
518 bool restart_syscalls) |
2705 | 519 { |
520 octave_interrupt_handler retval; | |
521 | |
522 #ifdef SIGINT | |
5770 | 523 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
|
524 restart_syscalls); |
2705 | 525 #endif |
526 | |
527 #ifdef SIGBREAK | |
5770 | 528 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
|
529 restart_syscalls); |
2705 | 530 #endif |
531 | |
532 return retval; | |
1651 | 533 } |
534 | |
635 | 535 // Install all the handlers for the signals we might care about. |
536 | |
1 | 537 void |
538 install_signal_handlers (void) | |
539 { | |
5142 | 540 for (int i = 0; i < NSIG; i++) |
541 octave_signals_caught[i] = false; | |
542 | |
2554 | 543 octave_catch_interrupts (); |
544 | |
1 | 545 #ifdef SIGABRT |
1446 | 546 octave_set_signal_handler (SIGABRT, generic_sig_handler); |
1 | 547 #endif |
548 | |
549 #ifdef SIGALRM | |
1446 | 550 octave_set_signal_handler (SIGALRM, generic_sig_handler); |
1 | 551 #endif |
552 | |
553 #ifdef SIGBUS | |
1446 | 554 octave_set_signal_handler (SIGBUS, generic_sig_handler); |
1 | 555 #endif |
556 | |
1230 | 557 #ifdef SIGCHLD |
1446 | 558 octave_set_signal_handler (SIGCHLD, sigchld_handler); |
1230 | 559 #endif |
560 | |
3174 | 561 // SIGCLD |
562 // SIGCONT | |
563 | |
1 | 564 #ifdef SIGEMT |
1446 | 565 octave_set_signal_handler (SIGEMT, generic_sig_handler); |
1 | 566 #endif |
567 | |
568 #ifdef SIGFPE | |
1373 | 569 #if defined (__alpha__) |
1446 | 570 octave_set_signal_handler (SIGFPE, sigfpe_handler); |
1373 | 571 #else |
1446 | 572 octave_set_signal_handler (SIGFPE, generic_sig_handler); |
1 | 573 #endif |
1373 | 574 #endif |
1 | 575 |
576 #ifdef SIGHUP | |
4449 | 577 octave_set_signal_handler (SIGHUP, sig_hup_or_term_handler); |
1 | 578 #endif |
579 | |
580 #ifdef SIGILL | |
1446 | 581 octave_set_signal_handler (SIGILL, generic_sig_handler); |
1 | 582 #endif |
583 | |
3174 | 584 // SIGINFO |
585 // SIGINT | |
586 | |
1 | 587 #ifdef SIGIOT |
1446 | 588 octave_set_signal_handler (SIGIOT, generic_sig_handler); |
1 | 589 #endif |
590 | |
591 #ifdef SIGLOST | |
1446 | 592 octave_set_signal_handler (SIGLOST, generic_sig_handler); |
1 | 593 #endif |
594 | |
595 #ifdef SIGPIPE | |
1446 | 596 octave_set_signal_handler (SIGPIPE, sigpipe_handler); |
1 | 597 #endif |
598 | |
599 #ifdef SIGPOLL | |
1446 | 600 octave_set_signal_handler (SIGPOLL, SIG_IGN); |
1 | 601 #endif |
602 | |
5866 | 603 // SIGPROF |
3174 | 604 // SIGPWR |
605 | |
1 | 606 #ifdef SIGQUIT |
1446 | 607 octave_set_signal_handler (SIGQUIT, generic_sig_handler); |
1 | 608 #endif |
609 | |
610 #ifdef SIGSEGV | |
1446 | 611 octave_set_signal_handler (SIGSEGV, generic_sig_handler); |
1 | 612 #endif |
613 | |
3174 | 614 // SIGSTOP |
615 | |
1 | 616 #ifdef SIGSYS |
1446 | 617 octave_set_signal_handler (SIGSYS, generic_sig_handler); |
1 | 618 #endif |
619 | |
620 #ifdef SIGTERM | |
4449 | 621 octave_set_signal_handler (SIGTERM, sig_hup_or_term_handler); |
1 | 622 #endif |
623 | |
624 #ifdef SIGTRAP | |
1446 | 625 octave_set_signal_handler (SIGTRAP, generic_sig_handler); |
1 | 626 #endif |
627 | |
3174 | 628 // SIGTSTP |
629 // SIGTTIN | |
630 // SIGTTOU | |
631 // SIGURG | |
632 | |
1 | 633 #ifdef SIGUSR1 |
1446 | 634 octave_set_signal_handler (SIGUSR1, generic_sig_handler); |
1 | 635 #endif |
636 | |
637 #ifdef SIGUSR2 | |
1446 | 638 octave_set_signal_handler (SIGUSR2, generic_sig_handler); |
1 | 639 #endif |
640 | |
641 #ifdef SIGVTALRM | |
1446 | 642 octave_set_signal_handler (SIGVTALRM, generic_sig_handler); |
1 | 643 #endif |
644 | |
895 | 645 #ifdef SIGIO |
1446 | 646 octave_set_signal_handler (SIGIO, SIG_IGN); |
895 | 647 #endif |
648 | |
3343 | 649 #if 0 |
3281 | 650 #ifdef SIGWINCH |
651 octave_set_signal_handler (SIGWINCH, sigwinch_handler); | |
652 #endif | |
3343 | 653 #endif |
3174 | 654 |
1 | 655 #ifdef SIGXCPU |
1446 | 656 octave_set_signal_handler (SIGXCPU, generic_sig_handler); |
1 | 657 #endif |
658 | |
659 #ifdef SIGXFSZ | |
1446 | 660 octave_set_signal_handler (SIGXFSZ, generic_sig_handler); |
1 | 661 #endif |
5451 | 662 |
1 | 663 } |
664 | |
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
|
665 static octave_scalar_map |
4294 | 666 make_sig_struct (void) |
667 { | |
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
|
668 octave_scalar_map m; |
4294 | 669 |
670 #ifdef SIGABRT | |
4675 | 671 m.assign ("ABRT", SIGABRT); |
4294 | 672 #endif |
673 | |
674 #ifdef SIGALRM | |
4675 | 675 m.assign ("ALRM", SIGALRM); |
4294 | 676 #endif |
677 | |
678 #ifdef SIGBUS | |
4675 | 679 m.assign ("BUS", SIGBUS); |
4294 | 680 #endif |
681 | |
682 #ifdef SIGCHLD | |
4675 | 683 m.assign ("CHLD", SIGCHLD); |
4294 | 684 #endif |
685 | |
686 #ifdef SIGCLD | |
4675 | 687 m.assign ("CLD", SIGCLD); |
4294 | 688 #endif |
689 | |
690 #ifdef SIGCONT | |
4675 | 691 m.assign ("CONT", SIGCONT); |
4294 | 692 #endif |
693 | |
694 #ifdef SIGEMT | |
4675 | 695 m.assign ("EMT", SIGEMT); |
4294 | 696 #endif |
697 | |
698 #ifdef SIGFPE | |
4675 | 699 m.assign ("FPE", SIGFPE); |
4294 | 700 #endif |
701 | |
702 #ifdef SIGHUP | |
4675 | 703 m.assign ("HUP", SIGHUP); |
4294 | 704 #endif |
705 | |
706 #ifdef SIGILL | |
4675 | 707 m.assign ("ILL", SIGILL); |
4294 | 708 #endif |
709 | |
710 #ifdef SIGINFO | |
4675 | 711 m.assign ("INFO", SIGINFO); |
4294 | 712 #endif |
713 | |
714 #ifdef SIGINT | |
4675 | 715 m.assign ("INT", SIGINT); |
4294 | 716 #endif |
717 | |
718 #ifdef SIGIOT | |
4675 | 719 m.assign ("IOT", SIGIOT); |
4294 | 720 #endif |
721 | |
722 #ifdef SIGLOST | |
4675 | 723 m.assign ("LOST", SIGLOST); |
4294 | 724 #endif |
725 | |
726 #ifdef SIGPIPE | |
4675 | 727 m.assign ("PIPE", SIGPIPE); |
4294 | 728 #endif |
729 | |
730 #ifdef SIGPOLL | |
4675 | 731 m.assign ("POLL", SIGPOLL); |
4294 | 732 #endif |
733 | |
734 #ifdef SIGPROF | |
4675 | 735 m.assign ("PROF", SIGPROF); |
4294 | 736 #endif |
737 | |
738 #ifdef SIGPWR | |
4675 | 739 m.assign ("PWR", SIGPWR); |
4294 | 740 #endif |
741 | |
742 #ifdef SIGQUIT | |
4675 | 743 m.assign ("QUIT", SIGQUIT); |
4294 | 744 #endif |
745 | |
746 #ifdef SIGSEGV | |
4675 | 747 m.assign ("SEGV", SIGSEGV); |
4294 | 748 #endif |
749 | |
750 #ifdef SIGSTOP | |
4675 | 751 m.assign ("STOP", SIGSTOP); |
4294 | 752 #endif |
753 | |
754 #ifdef SIGSYS | |
4675 | 755 m.assign ("SYS", SIGSYS); |
4294 | 756 #endif |
757 | |
758 #ifdef SIGTERM | |
4675 | 759 m.assign ("TERM", SIGTERM); |
4294 | 760 #endif |
761 | |
762 #ifdef SIGTRAP | |
4675 | 763 m.assign ("TRAP", SIGTRAP); |
4294 | 764 #endif |
765 | |
766 #ifdef SIGTSTP | |
4675 | 767 m.assign ("TSTP", SIGTSTP); |
4294 | 768 #endif |
769 | |
770 #ifdef SIGTTIN | |
4675 | 771 m.assign ("TTIN", SIGTTIN); |
4294 | 772 #endif |
773 | |
774 #ifdef SIGTTOU | |
4675 | 775 m.assign ("TTOU", SIGTTOU); |
4294 | 776 #endif |
777 | |
778 #ifdef SIGURG | |
4675 | 779 m.assign ("URG", SIGURG); |
4294 | 780 #endif |
781 | |
782 #ifdef SIGUSR1 | |
4675 | 783 m.assign ("USR1", SIGUSR1); |
4294 | 784 #endif |
785 | |
786 #ifdef SIGUSR2 | |
4675 | 787 m.assign ("USR2", SIGUSR2); |
4294 | 788 #endif |
789 | |
790 #ifdef SIGVTALRM | |
4675 | 791 m.assign ("VTALRM", SIGVTALRM); |
4294 | 792 #endif |
793 | |
794 #ifdef SIGIO | |
4675 | 795 m.assign ("IO", SIGIO); |
4294 | 796 #endif |
797 | |
798 #ifdef SIGWINCH | |
4675 | 799 m.assign ("WINCH", SIGWINCH); |
4294 | 800 #endif |
801 | |
802 #ifdef SIGXCPU | |
4675 | 803 m.assign ("XCPU", SIGXCPU); |
4294 | 804 #endif |
805 | |
806 #ifdef SIGXFSZ | |
4675 | 807 m.assign ("XFSZ", SIGXFSZ); |
4294 | 808 #endif |
809 | |
810 return m; | |
811 } | |
812 | |
5142 | 813 octave_child_list::octave_child_list_rep *octave_child_list::instance = 0; |
5128 | 814 |
2926 | 815 bool |
816 octave_child_list::instance_ok (void) | |
817 { | |
818 bool retval = true; | |
819 | |
820 if (! instance) | |
5142 | 821 instance = new octave_child_list_rep (); |
2926 | 822 |
823 if (! instance) | |
824 { | |
825 ::error ("unable to create child list object!"); | |
826 | |
827 retval = false; | |
828 } | |
829 | |
830 return retval; | |
831 } | |
832 | |
833 void | |
5142 | 834 octave_child_list::insert (pid_t pid, octave_child::child_event_handler f) |
835 { | |
836 if (instance_ok ()) | |
837 instance->insert (pid, f); | |
838 } | |
839 | |
840 void | |
841 octave_child_list::reap (void) | |
2926 | 842 { |
843 if (instance_ok ()) | |
5142 | 844 instance->reap (); |
845 } | |
846 | |
847 bool | |
848 octave_child_list::wait (void) | |
849 { | |
850 return (instance_ok ()) ? instance->wait () : false; | |
2926 | 851 } |
852 | |
5142 | 853 class pid_equal |
854 { | |
855 public: | |
856 | |
857 pid_equal (pid_t v) : val (v) { } | |
858 | |
859 bool operator () (const octave_child& oc) const { return oc.pid == val; } | |
860 | |
861 private: | |
862 | |
863 pid_t val; | |
864 }; | |
865 | |
2926 | 866 void |
867 octave_child_list::remove (pid_t pid) | |
868 { | |
869 if (instance_ok ()) | |
5142 | 870 instance->remove_if (pid_equal (pid)); |
2926 | 871 } |
872 | |
5142 | 873 #define OCL_REP octave_child_list::octave_child_list_rep |
2926 | 874 |
5142 | 875 void |
876 OCL_REP::insert (pid_t pid, octave_child::child_event_handler f) | |
2926 | 877 { |
5142 | 878 append (octave_child (pid, f)); |
2926 | 879 } |
880 | |
2209 | 881 void |
5142 | 882 OCL_REP::reap (void) |
2209 | 883 { |
5142 | 884 // Mark the record for PID invalid. |
2209 | 885 |
5142 | 886 for (iterator p = begin (); p != end (); p++) |
887 { | |
888 // The call to the octave_child::child_event_handler might | |
889 // invalidate the iterator (for example, by calling | |
890 // octave_child_list::remove), so we increment the iterator | |
891 // here. | |
2209 | 892 |
5142 | 893 octave_child& oc = *p; |
2209 | 894 |
5142 | 895 if (oc.have_status) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
896 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
897 oc.have_status = 0; |
5142 | 898 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
899 octave_child::child_event_handler f = oc.handler; |
5142 | 900 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
901 if (f && f (oc.pid, oc.status)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
902 oc.pid = -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
903 } |
2209 | 904 } |
905 | |
5142 | 906 remove_if (pid_equal (-1)); |
2209 | 907 } |
908 | |
5142 | 909 // Wait on our children and record any changes in their status. |
910 | |
911 bool | |
912 OCL_REP::wait (void) | |
2210 | 913 { |
5142 | 914 bool retval = false; |
2210 | 915 |
5142 | 916 for (iterator p = begin (); p != end (); p++) |
2210 | 917 { |
5142 | 918 octave_child& oc = *p; |
919 | |
920 pid_t pid = oc.pid; | |
921 | |
922 if (pid > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
923 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
924 int status; |
2210 | 925 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
926 if (octave_syscalls::waitpid (pid, &status, WNOHANG) > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
927 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
928 oc.have_status = 1; |
5142 | 929 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
930 oc.status = status; |
5142 | 931 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
932 retval = true; |
5142 | 933 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
934 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
935 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10246
diff
changeset
|
936 } |
2210 | 937 } |
938 | |
5142 | 939 return retval; |
2210 | 940 } |
941 | |
5780 | 942 DEFUN (SIG, args, , |
943 "-*- texinfo -*-\n\ | |
944 @deftypefn {Built-in Function} {} SIG ()\n\ | |
945 Return a structure containing Unix signal names and their defined values.\n\ | |
946 @end deftypefn") | |
947 { | |
948 octave_value retval; | |
949 | |
950 if (args.length () == 0) | |
951 { | |
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
|
952 static octave_scalar_map m = make_sig_struct (); |
5780 | 953 |
954 retval = m; | |
955 } | |
956 else | |
5823 | 957 print_usage (); |
5780 | 958 |
959 return retval; | |
960 } | |
961 | |
5794 | 962 DEFUN (debug_on_interrupt, args, nargout, |
963 "-*- texinfo -*-\n\ | |
10840 | 964 @deftypefn {Built-in Function} {@var{val} =} debug_on_interrupt ()\n\ |
5794 | 965 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_interrupt (@var{new_val})\n\ |
966 Query or set the internal variable that controls whether Octave will try\n\ | |
967 to enter debugging mode when it receives an interrupt signal (typically\n\ | |
968 generated with @kbd{C-c}). If a second interrupt signal is received\n\ | |
969 before reaching the debugging mode, a normal interrupt will occur.\n\ | |
970 @end deftypefn") | |
4449 | 971 { |
5794 | 972 return SET_INTERNAL_VARIABLE (debug_on_interrupt); |
4449 | 973 } |
974 | |
5794 | 975 DEFUN (sighup_dumps_octave_core, args, nargout, |
976 "-*- texinfo -*-\n\ | |
10840 | 977 @deftypefn {Built-in Function} {@var{val} =} sighup_dumps_octave_core ()\n\ |
5794 | 978 @deftypefnx {Built-in Function} {@var{old_val} =} sighup_dumps_octave_core (@var{new_val})\n\ |
979 Query or set the internal variable that controls whether Octave tries\n\ | |
6653 | 980 to save all current variables to the file \"octave-core\" if it receives\n\ |
5794 | 981 a hangup signal.\n\ |
982 @end deftypefn") | |
4185 | 983 { |
5794 | 984 return SET_INTERNAL_VARIABLE (sighup_dumps_octave_core); |
985 } | |
4294 | 986 |
5794 | 987 DEFUN (sigterm_dumps_octave_core, args, nargout, |
988 "-*- texinfo -*-\n\ | |
10840 | 989 @deftypefn {Built-in Function} {@var{val} =} sigterm_dumps_octave_core ()\n\ |
5794 | 990 @deftypefnx {Built-in Function} {@var{old_val} =} sigterm_dumps_octave_core (@var{new_val})\n\ |
991 Query or set the internal variable that controls whether Octave tries\n\ | |
6653 | 992 to save all current variables to the file \"octave-core\" if it receives\n\ |
5794 | 993 a terminate signal.\n\ |
994 @end deftypefn") | |
995 { | |
996 return SET_INTERNAL_VARIABLE (sigterm_dumps_octave_core); | |
4185 | 997 } |