Mercurial > octave
annotate libinterp/corefcn/sighandlers.cc @ 24520:c5c11b07598a
refactor signal handling (bug #52757)
Given that any library code may now be multi-threaded it is not likely
to be save to jump out of a signal handler when executing a call to a
library function. We are almost assured to fail if the call to
siglongjmp occurs in a different thread from the corresponding call to
sigsetjmp.
Similarly, we should avoid calling the interrupt signal handler
function in an arbitrary thread. This is already done by default on
Windows systems. On Posix systems, we now set up a separate thread to
handle asynchronous signals (not just SIGINT). We no longer attempt
to jump out of the signal handler. Instead, we only set global status
variables and respond to them in octave_quit. This means that some
external library functions are no longer interruptible. If that
becomes important, then we will need to look for other alternatives
such as setting up worker threads that can be canceled when a SIGINT
is detected.
* sighandlers.cc (interrupt_manager, base_interrupt_manager,
w32_interrupt_manager, posix_interrupt_manager): Delete classes and
all uses.
(respond_to_pending_signals): Rename from signal_handler. Change all
uses. Take action on more signals.
(generic_sig_handler): Simply record that a signal was caught and add
it to the list of caught signals.
(deadly_sig_handler): New function.
(fpe_sig_handler): Rename from sigfpe_handler. Don't make specific to
Alpha systems. Simply warn that an exception has occurred.
(sigint_handler): Simply record that an interrupt signal was caught.
(sigterm_handler, sigpipe_handler): Delete.
(install_signal_handlers): Rework actions for various signals.
(Vsigquit_dumps_octave_core): New static variable.
(Fsigquit_dumps_octave_core): New function.
* io.txi: Document sigquit_dumps_octave_core.
* f77-fcn.h, f77-fcn.c (xSTRINGIZE, STRINGIZE, F77_XFCN_ERROR):
Delete macros.
(F77_XFCN): Don't do setjmp/longjmp exception handling.
(f77_exception_encountered): Delete global variable.
(XSTOPX): Don't set f77_exception_encountered. If message is empty,
report "unknown error in fortran subroutine".
* eigs-base.cc, gsvd.cc: Delete all direct uses of
f77_exception_encountered.
* liboctave/util/f77-extern.cc: Delete file.
* liboctave/util/module.mk: Update.
* cmd-edit.h, cmd-edit.cc (command_editor::interrupt_exception): New class.
(command_editor::handle_interrupt_signal): New static function.
(command_editor::do_handle_interrupt_signal): New virtual function.
(command_editor::event_hanlder): Call handle_interrupt_signal if
octave_interrupt_state is not zero.
(command_editor::instance_ok): Set event hook here.
(command_editor::add_event_hook): Not here.
(command_editor::remove_event_hook): Never remove event hook.
(gnu_readline::do_handle_interrupt_signal): New function.
(gnu_readline::do_readline): Retry if an interrupt exception occurs
inside readline.
* oct-rl-edit.h, oct-rl-edit.c (octave_rl_recover_from_interrupt):
New function.
* quit.h, cquit.c (current_context, octave_save_current_context,
octave_restore_current_context, octave_jump_to_enclosing_context,
octave_interrupt_immediately, octave_jmp_buf): Delete.
* quit.h: Don't include <setjmp.h>
(octave_set_current_context): Delete macro.
(octave_exit_exception_status, octave_exit_exception_safe_to_return):
Mark as deprecated.
(BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_1): Delete.
(BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_2): Delete.
(BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE,
END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE): Define to only create a
dummy do-while scope.
(BEGIN_INTERRUPT_WITH_EXCEPTIONS, END_INTERRUPT_WITH_EXCEPTIONS):
Define to only create a dummy scope.
* interpreter.cc (interpreter::recover_from_exception):
Don't reset octave_interrupt_immediately.
* main-cli.cc (main): Call octave_block_async_signals.
* main.in.cc (main): Call octave_block_async_signals initially.
Only in install signal handlers and unblock signals if starting
managed subprocess.
* main-window.cc (octave_interpreter::executed):
Don't unblock interrupt signals.
* signal-wrappers.h, signal-wrappers.c
(signal_watcher, octave_async_signals, block_or_unblock_signal_by_name): New static functions.
(octave_set_default_signal_handler,
octave_set_default_signal_handler_by_name,
octave_block_signal_by_name, octave_unblock_signal_by_name,
octave_create_interrupt_watcher_thread, octave_block_async_signals,
octave_unblock_async_signals): New functions.
(octave_block_interrupt_signal, octave_unblock_interrupt_signal):
Treat SIGBREAK as an interrupt signal.
(octave_block_child): Also handle SIGCLD the same as SIGCHLD.
(print_sigset, print_sigmask): New static functions.
(octave_show_sigmask): New function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 03 Jan 2018 07:52:11 -0500 |
parents | f87c9f5c0f43 |
children | a8eb8a734b9d |
rev | line source |
---|---|
1 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1993-2017 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
1 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
1 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21609
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
24 # include "config.h" |
1 | 25 #endif |
26 | |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
27 #include <csignal> |
2536 | 28 #include <cstdlib> |
29 | |
3503 | 30 #include <iostream> |
1344 | 31 #include <new> |
32 | |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
33 #if defined (OCTAVE_USE_WINDOWS_API) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
34 # define WIN32_LEAN_AND_MEAN |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
35 # include <windows.h> |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
36 #endif |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
37 |
3281 | 38 #include "cmd-edit.h" |
5453 | 39 #include "oct-syscalls.h" |
4153 | 40 #include "quit.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13951
diff
changeset
|
41 #include "singleton-cleanup.h" |
21938
da9b960b1b2d
use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
21936
diff
changeset
|
42 #include "signal-wrappers.h" |
3281 | 43 |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
23101
diff
changeset
|
44 #include "bp-table.h" |
4185 | 45 #include "defun.h" |
1352 | 46 #include "error.h" |
10194 | 47 #include "input.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
48 #include "interpreter.h" |
1373 | 49 #include "load-save.h" |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
50 #include "octave.h" |
4294 | 51 #include "oct-map.h" |
2091 | 52 #include "pager.h" |
4185 | 53 #include "pt-bp.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
54 #include "pt-eval.h" |
1 | 55 #include "sighandlers.h" |
4787 | 56 #include "sysdep.h" |
1 | 57 #include "utils.h" |
5794 | 58 #include "variables.h" |
1 | 59 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
60 namespace octave |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
61 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
62 // Nonzero means we have already printed a message for this series of |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
63 // SIGPIPES. We assume that the writer will eventually give up. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
64 int pipe_handler_error_count = 0; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
65 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
66 // TRUE means we can be interrupted. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
67 bool can_interrupt = false; |
1 | 68 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
69 // TRUE means we should try to enter the debugger on SIGINT. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
70 bool Vdebug_on_interrupt = false; |
1 | 71 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
72 // Allow users to avoid writing octave-workspace for SIGHUP (sent by |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
73 // closing gnome-terminal, for example). Note that this variable has |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
74 // no effect if Vcrash_dumps_octave_core is FALSE. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
75 static bool Vsighup_dumps_octave_core = true; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
76 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
77 // Similar to Vsighup_dumps_octave_core, but for SIGQUIT signal. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
78 static bool Vsigquit_dumps_octave_core = true; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
79 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
80 // Similar to Vsighup_dumps_octave_core, but for SIGTERM signal. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
81 static bool Vsigterm_dumps_octave_core = true; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
82 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
83 // List of signals we have caught since last call to signal_handler. |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
84 static bool *signals_caught = nullptr; |
4185 | 85 |
23096
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
86 static void |
23101
86376c04cb66
generate signal name from number when needed in signal handler functions
John W. Eaton <jwe@octave.org>
parents:
23096
diff
changeset
|
87 my_friendly_exit (int sig, bool save_vars = true) |
23096
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
88 { |
23101
86376c04cb66
generate signal name from number when needed in signal handler functions
John W. Eaton <jwe@octave.org>
parents:
23096
diff
changeset
|
89 std::cerr << "fatal: caught signal " |
86376c04cb66
generate signal name from number when needed in signal handler functions
John W. Eaton <jwe@octave.org>
parents:
23096
diff
changeset
|
90 << octave_strsignal_wrapper (sig) |
23096
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
91 << " -- stopping myself..." << std::endl; |
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
92 |
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
93 if (save_vars) |
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
94 dump_octave_core (); |
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
95 |
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
96 sysdep_cleanup (); |
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
97 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
98 throw exit_exception (1); |
23096
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
99 } |
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
100 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
101 // Called from octave_quit () to actually do something about the signals |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
102 // we have caught. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
103 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
104 void |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
105 respond_to_pending_signals (void) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
106 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
107 // The list of signals is relatively short, so we will just go |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
108 // linearly through the list. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
109 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
110 // Interrupt signals are currently handled separately. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
111 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
112 static int sigint; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
113 static const bool have_sigint |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
114 = octave_get_sig_number ("SIGINT", &sigint); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
115 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
116 static int sigbreak; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
117 static const bool have_sigbreak |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
118 = octave_get_sig_number ("SIGBREAK", &sigbreak); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
119 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
120 // Termination signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
121 |
23096
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
122 static int sighup; |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
123 static const bool have_sighup |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
124 = octave_get_sig_number ("SIGHUP", &sighup); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
125 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
126 static int sigquit; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
127 static const bool have_sigquit |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
128 = octave_get_sig_number ("SIGQUIT", &sigquit); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
129 |
23096
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
130 static int sigterm; |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
131 static const bool have_sigterm |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
132 = octave_get_sig_number ("SIGTERM", &sigterm); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
133 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
134 // Alarm signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
135 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
136 static int sigalrm; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
137 static const bool have_sigalrm |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
138 = octave_get_sig_number ("SIGALRM", &sigalrm); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
139 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
140 // I/O signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
141 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
142 static int sigio; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
143 static const bool have_sigio |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
144 = octave_get_sig_number ("SIGIO", &sigio); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
145 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
146 static int siglost; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
147 static const bool have_siglost |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
148 = octave_get_sig_number ("SIGLOST", &siglost); |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
149 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
150 static int sigpipe; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
151 static const bool have_sigpipe |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
152 = octave_get_sig_number ("SIGPIPE", &sigpipe); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
153 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
154 // Job control signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
155 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
156 static int sigchld; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
157 static const bool have_sigchld |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
158 = octave_get_sig_number ("SIGCHLD", &sigchld); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
159 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
160 static int sigcld; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
161 static const bool have_sigcld |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
162 = octave_get_sig_number ("SIGCLD", &sigcld); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
163 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
164 // Resource limit signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
165 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
166 static int sigxcpu; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
167 static const bool have_sigxcpu |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
168 = octave_get_sig_number ("SIGXCPU", &sigxcpu); |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
169 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
170 static int sigxfsz; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
171 static const bool have_sigxfsz |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
172 = octave_get_sig_number ("SIGXFSZ", &sigxfsz); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
173 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
174 // User signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
175 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
176 static int sigusr1; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
177 static const bool have_sigusr1 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
178 = octave_get_sig_number ("SIGUSR1", &sigusr1); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
179 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
180 static int sigusr2; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
181 static const bool have_sigusr2 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
182 = octave_get_sig_number ("SIGUSR2", &sigusr2); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
183 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
184 for (int sig = 0; sig < octave_num_signals (); sig++) |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
185 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
186 if (signals_caught[sig]) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
187 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
188 signals_caught[sig] = false; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
189 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
190 if ((have_sigchld && sig == sigchld) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
191 || (have_sigcld && sig == sigcld)) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
192 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
193 // FIXME: should we block or ignore? |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
194 volatile interrupt_handler saved_interrupt_handler |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
195 = ignore_interrupts (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
196 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
197 void *context = octave_block_child (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
198 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
199 child_list::wait (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
200 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
201 set_interrupt_handler (saved_interrupt_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
202 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
203 octave_unblock_child (context); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
204 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
205 child_list::reap (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
206 } |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
207 else if (have_sigpipe && sig == sigpipe) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
208 { |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
209 std::cerr << "warning: broken pipe" << std::endl; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
210 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
211 // Don't loop forever on account of this. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
212 // FIXME: is this really needed? Does it do anything |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
213 // useful now? |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
214 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
215 if (pipe_handler_error_count++ > 100 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
216 && octave_interrupt_state >= 0) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
217 octave_interrupt_state++; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
218 } |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
219 else if (have_sighup && sig == sighup) |
23101
86376c04cb66
generate signal name from number when needed in signal handler functions
John W. Eaton <jwe@octave.org>
parents:
23096
diff
changeset
|
220 my_friendly_exit (sighup, Vsighup_dumps_octave_core); |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
221 else if (have_sigquit && sig == sigquit) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
222 my_friendly_exit (sigquit, Vsigquit_dumps_octave_core); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
223 else if (have_sigterm && sig == sigterm) |
23101
86376c04cb66
generate signal name from number when needed in signal handler functions
John W. Eaton <jwe@octave.org>
parents:
23096
diff
changeset
|
224 my_friendly_exit (sigterm, Vsigterm_dumps_octave_core); |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
225 else if ((have_sigalrm && sig == sigalrm) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
226 || (have_sigio && sig == sigio) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
227 || (have_siglost && sig == siglost) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
228 || (have_sigxcpu && sig == sigxcpu) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
229 || (have_sigxfsz && sig == sigxfsz) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
230 || (have_sigusr1 && sig == sigusr1) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
231 || (have_sigusr2 && sig == sigusr2)) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
232 std::cerr << "warning: ignoring signal: " |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
233 << octave_strsignal_wrapper (sig) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
234 << std::endl; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
235 else if ((have_sigint && sig == sigint) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
236 || (have_sigbreak && sig == sigbreak)) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
237 /* handled separately; do nothing */; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
238 else |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
239 std::cerr << "warning: ignoring unexpected signal: " |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
240 << octave_strsignal_wrapper (sig) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
241 << std::endl; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
242 } |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
243 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
244 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
245 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
246 sig_handler * |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
247 set_signal_handler (int sig, sig_handler *handler, bool restart_syscalls) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
248 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
249 return octave_set_signal_handler_internal (sig, handler, restart_syscalls); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
250 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
251 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
252 sig_handler * |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
253 set_signal_handler (const char *signame, sig_handler *handler, |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22382
diff
changeset
|
254 bool restart_syscalls) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
255 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
256 return octave_set_signal_handler_by_name (signame, handler, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
257 restart_syscalls); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
258 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
259 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
260 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
261 generic_sig_handler (int sig) |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
262 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
263 // FIXME: this function may execute in a separate signal handler or |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
264 // signal watcher thread so it should probably be more careful about |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
265 // how it accesses global objects. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
266 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
267 octave_signal_caught = 1; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
268 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
269 signals_caught[sig] = true; |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
270 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
271 static int sigint; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
272 static const bool have_sigint |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
273 = octave_get_sig_number ("SIGINT", &sigint); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
274 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
275 static int sigbreak; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
276 static const bool have_sigbreak |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
277 = octave_get_sig_number ("SIGBREAK", &sigbreak); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
278 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
279 if ((have_sigint && sig == sigint) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
280 || (have_sigbreak && sig == sigbreak)) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
281 octave_interrupt_state++; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
282 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
283 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
284 static void |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
285 deadly_sig_handler (int sig) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
286 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
287 std::cerr << "fatal: caught signal " |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
288 << octave_strsignal_wrapper (sig) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
289 << " -- stopping myself..." << std::endl; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
290 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
291 octave_set_default_signal_handler (sig); |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
292 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
293 octave_raise_wrapper (sig); |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
294 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
295 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
296 static void |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
297 fpe_sig_handler (int) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
298 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
299 // FIXME: is there something better we can do? |
23096
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
300 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
301 std::cerr << "warning: floating point exception" << std::endl; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
302 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
303 |
23096
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
304 // Handle SIGINT. |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
305 // |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
306 // This also has to work for SIGBREAK (on systems that have it), so we |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
307 // use the value of sig, instead of just assuming that it is called |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
308 // for SIGINT only. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
309 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
310 static void |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
311 sigint_handler (int) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
312 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
313 if (! octave_initialized) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
314 exit (1); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
315 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
316 if (can_interrupt) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
317 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
318 octave_signal_caught = 1; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
319 octave_interrupt_state++; |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
320 } |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
321 } |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
322 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
323 interrupt_handler |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
324 catch_interrupts (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
325 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
326 interrupt_handler retval; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
327 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
328 retval.int_handler = set_signal_handler ("SIGINT", sigint_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
329 retval.brk_handler = set_signal_handler ("SIGBREAK", sigint_handler); |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
330 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
331 return retval; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
332 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
333 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
334 interrupt_handler |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
335 ignore_interrupts (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
336 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
337 interrupt_handler retval; |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
338 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
339 retval.int_handler = set_signal_handler ("SIGINT", SIG_IGN); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
340 retval.brk_handler = set_signal_handler ("SIGBREAK", SIG_IGN); |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
341 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
342 return retval; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
343 } |
11555
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
344 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
345 interrupt_handler |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
346 set_interrupt_handler (const volatile interrupt_handler& h, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
347 bool restart_syscalls) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
348 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
349 interrupt_handler retval; |
5142 | 350 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
351 retval.int_handler = set_signal_handler ("SIGINT", h.int_handler, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
352 restart_syscalls); |
5142 | 353 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
354 retval.brk_handler = set_signal_handler ("SIGBREAK", h.brk_handler, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
355 restart_syscalls); |
2536 | 356 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
357 return retval; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
358 } |
5451 | 359 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
360 // Install all the handlers for the signals we might care about. |
1373 | 361 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
362 void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
363 install_signal_handlers (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
364 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
365 if (! signals_caught) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
366 signals_caught = new bool [octave_num_signals ()]; |
5451 | 367 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
368 for (int i = 0; i < octave_num_signals (); i++) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
369 signals_caught[i] = false; |
3162 | 370 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
371 // Interrupt signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
372 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
373 catch_interrupts (); |
5144 | 374 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
375 // Program Error signals. These are most likely unrecoverable for |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
376 // us. |
1446 | 377 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
378 set_signal_handler ("SIGABRT", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
379 set_signal_handler ("SIGBUS", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
380 set_signal_handler ("SIGEMT", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
381 set_signal_handler ("SIGILL", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
382 // SIGIOT is normally another name for SIGABRT. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
383 set_signal_handler ("SIGIOT", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
384 set_signal_handler ("SIGSEGV", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
385 set_signal_handler ("SIGSYS", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
386 set_signal_handler ("SIGTRAP", deadly_sig_handler); |
1230 | 387 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
388 // Handle SIGFPE separately. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
389 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
390 set_signal_handler ("SIGFPE", fpe_sig_handler); |
3281 | 391 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
392 // Handle other signals for which the default action is to terminate |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
393 // the program. |
4172 | 394 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
395 // Termination signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
396 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
397 set_signal_handler ("SIGHUP", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
398 set_signal_handler ("SIGQUIT", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
399 set_signal_handler ("SIGTERM", generic_sig_handler); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
400 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
401 // Alarm signals. |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
402 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
403 set_signal_handler ("SIGALRM", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
404 set_signal_handler ("SIGVTALRM", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
405 set_signal_handler ("SIGPROF", generic_sig_handler); |
4793 | 406 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
407 // I/O signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
408 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
409 set_signal_handler ("SIGLOST", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
410 set_signal_handler ("SIGPIPE", generic_sig_handler); |
4787 | 411 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
412 // Job control signals. We only recognize signals about child |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
413 // processes. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
414 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
415 set_signal_handler ("SIGCHLD", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
416 set_signal_handler ("SIGCLD", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
417 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
418 // Resource limit signals. |
5451 | 419 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
420 // FIXME: does it really make sense to try to handle the CPU limit |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
421 // signal? |
1 | 422 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
423 set_signal_handler ("SIGXCPU", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
424 set_signal_handler ("SIGXFSZ", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
425 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
426 // User signals. |
2554 | 427 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
428 set_signal_handler ("SIGUSR1", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
429 set_signal_handler ("SIGUSR2", generic_sig_handler); |
2705 | 430 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
431 // This does nothing on Windows systems. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
432 octave_create_interrupt_watcher_thread (generic_sig_handler); |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
433 } |
635 | 434 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
435 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
436 set_sig_struct_field (octave_scalar_map& m, const char *signame) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
437 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
438 int signum; |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
439 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
440 // The names in the struct do not include the leading "SIG" prefix. |
1 | 441 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
442 if (octave_get_sig_number (signame, &signum)) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
443 m.assign (&signame[3], signum); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
444 } |
3174 | 445 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
446 static octave_scalar_map |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
447 make_sig_struct (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
448 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
449 octave_scalar_map m; |
3174 | 450 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
451 set_sig_struct_field (m, "SIGABRT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
452 set_sig_struct_field (m, "SIGALRM"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
453 set_sig_struct_field (m, "SIGBUS"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
454 set_sig_struct_field (m, "SIGCHLD"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
455 set_sig_struct_field (m, "SIGCLD"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
456 set_sig_struct_field (m, "SIGCONT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
457 set_sig_struct_field (m, "SIGEMT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
458 set_sig_struct_field (m, "SIGFPE"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
459 set_sig_struct_field (m, "SIGHUP"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
460 set_sig_struct_field (m, "SIGILL"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
461 set_sig_struct_field (m, "SIGINFO"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
462 set_sig_struct_field (m, "SIGINT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
463 set_sig_struct_field (m, "SIGIO"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
464 set_sig_struct_field (m, "SIGIOT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
465 set_sig_struct_field (m, "SIGKILL"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
466 set_sig_struct_field (m, "SIGLOST"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
467 set_sig_struct_field (m, "SIGPIPE"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
468 set_sig_struct_field (m, "SIGPOLL"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
469 set_sig_struct_field (m, "SIGPROF"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
470 set_sig_struct_field (m, "SIGPWR"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
471 set_sig_struct_field (m, "SIGQUIT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
472 set_sig_struct_field (m, "SIGSEGV"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
473 set_sig_struct_field (m, "SIGSTKFLT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
474 set_sig_struct_field (m, "SIGSTOP"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
475 set_sig_struct_field (m, "SIGSYS"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
476 set_sig_struct_field (m, "SIGTERM"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
477 set_sig_struct_field (m, "SIGTRAP"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
478 set_sig_struct_field (m, "SIGTSTP"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
479 set_sig_struct_field (m, "SIGTTIN"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
480 set_sig_struct_field (m, "SIGTTOU"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
481 set_sig_struct_field (m, "SIGUNUSED"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
482 set_sig_struct_field (m, "SIGURG"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
483 set_sig_struct_field (m, "SIGUSR1"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
484 set_sig_struct_field (m, "SIGUSR2"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
485 set_sig_struct_field (m, "SIGVTALRM"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
486 set_sig_struct_field (m, "SIGWINCH"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
487 set_sig_struct_field (m, "SIGXCPU"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
488 set_sig_struct_field (m, "SIGXFSZ"); |
4294 | 489 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
490 return m; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
491 } |
4294 | 492 } |
493 | |
5780 | 494 DEFUN (SIG, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
495 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
496 @deftypefn {} {} SIG () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
497 Return a structure containing Unix signal names and their defined values. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
498 @end deftypefn */) |
5780 | 499 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
500 if (args.length () != 0) |
5823 | 501 print_usage (); |
5780 | 502 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
503 static octave_scalar_map m = octave::make_sig_struct (); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
504 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
505 return ovl (m); |
5780 | 506 } |
507 | |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
508 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
509 %!assert (isstruct (SIG ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
510 %!assert (! isempty (SIG ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
511 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
512 %!error SIG (1) |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
513 */ |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
514 |
5794 | 515 DEFUN (debug_on_interrupt, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
516 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
517 @deftypefn {} {@var{val} =} debug_on_interrupt () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
518 @deftypefnx {} {@var{old_val} =} debug_on_interrupt (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
519 @deftypefnx {} {} debug_on_interrupt (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
520 Query or set the internal variable that controls whether Octave will try |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
521 to enter debugging mode when it receives an interrupt signal (typically |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
522 generated with @kbd{C-c}). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
523 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
524 If a second interrupt signal is received before reaching the debugging mode, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
525 a normal interrupt will occur. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
526 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
527 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
528 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
529 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
530 @seealso{debug_on_error, debug_on_warning} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
531 @end deftypefn */) |
4449 | 532 { |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
533 return set_internal_variable (octave::Vdebug_on_interrupt, args, nargout, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
534 "debug_on_interrupt"); |
4449 | 535 } |
536 | |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
537 /* |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
538 %!test |
12832 | 539 %! orig_val = debug_on_interrupt (); |
540 %! old_val = debug_on_interrupt (! orig_val); | |
541 %! assert (orig_val, old_val); | |
542 %! assert (debug_on_interrupt (), ! orig_val); | |
543 %! debug_on_interrupt (orig_val); | |
544 %! 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
|
545 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
546 %!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
|
547 */ |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
548 |
5794 | 549 DEFUN (sighup_dumps_octave_core, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
550 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
551 @deftypefn {} {@var{val} =} sighup_dumps_octave_core () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
552 @deftypefnx {} {@var{old_val} =} sighup_dumps_octave_core (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
553 @deftypefnx {} {} sighup_dumps_octave_core (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
554 Query or set the internal variable that controls whether Octave tries |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
555 to save all current variables to the file @file{octave-workspace} if it |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
556 receives a hangup signal. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
557 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
558 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
559 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
560 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
561 @end deftypefn */) |
4185 | 562 { |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
563 return set_internal_variable (octave::Vsighup_dumps_octave_core, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
564 args, nargout, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
565 "sighup_dumps_octave_core"); |
5794 | 566 } |
4294 | 567 |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
568 /* |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
569 %!test |
12832 | 570 %! orig_val = sighup_dumps_octave_core (); |
571 %! old_val = sighup_dumps_octave_core (! orig_val); | |
572 %! assert (orig_val, old_val); | |
573 %! assert (sighup_dumps_octave_core (), ! orig_val); | |
574 %! sighup_dumps_octave_core (orig_val); | |
575 %! 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
|
576 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
577 %!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
|
578 */ |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
579 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
580 DEFUN (sigquit_dumps_octave_core, args, nargout, |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
581 doc: /* -*- texinfo -*- |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
582 @deftypefn {} {@var{val} =} sigquit_dumps_octave_core () |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
583 @deftypefnx {} {@var{old_val} =} sigquit_dumps_octave_core (@var{new_val}) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
584 @deftypefnx {} {} sigquit_dumps_octave_core (@var{new_val}, "local") |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
585 Query or set the internal variable that controls whether Octave tries |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
586 to save all current variables to the file @file{octave-workspace} if it |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
587 receives a quit signal. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
588 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
589 When called from inside a function with the @qcode{"local"} option, the |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
590 variable is changed locally for the function and any subroutines it calls. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
591 The original variable value is restored when exiting the function. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
592 @end deftypefn */) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
593 { |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
594 return set_internal_variable (octave::Vsigquit_dumps_octave_core, |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
595 args, nargout, |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
596 "sigquit_dumps_octave_core"); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
597 } |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
598 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
599 /* |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
600 %!test |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
601 %! orig_val = sigquit_dumps_octave_core (); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
602 %! old_val = sigquit_dumps_octave_core (! orig_val); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
603 %! assert (orig_val, old_val); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
604 %! assert (sigquit_dumps_octave_core (), ! orig_val); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
605 %! sigquit_dumps_octave_core (orig_val); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
606 %! assert (sigquit_dumps_octave_core (), orig_val); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
607 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
608 %!error (sigquit_dumps_octave_core (1, 2)) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
609 */ |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
610 |
5794 | 611 DEFUN (sigterm_dumps_octave_core, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
612 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
613 @deftypefn {} {@var{val} =} sigterm_dumps_octave_core () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
614 @deftypefnx {} {@var{old_val} =} sigterm_dumps_octave_core (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
615 @deftypefnx {} {} sigterm_dumps_octave_core (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
616 Query or set the internal variable that controls whether Octave tries |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
617 to save all current variables to the file @file{octave-workspace} if it |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
618 receives a terminate signal. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
619 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
620 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
621 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
622 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
623 @end deftypefn */) |
5794 | 624 { |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
625 return set_internal_variable (octave::Vsigterm_dumps_octave_core, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
626 args, nargout, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
627 "sigterm_dumps_octave_core"); |
4185 | 628 } |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
629 |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
630 /* |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
631 %!test |
12832 | 632 %! orig_val = sigterm_dumps_octave_core (); |
633 %! old_val = sigterm_dumps_octave_core (! orig_val); | |
634 %! assert (orig_val, old_val); | |
635 %! assert (sigterm_dumps_octave_core (), ! orig_val); | |
636 %! sigterm_dumps_octave_core (orig_val); | |
637 %! 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
|
638 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
639 %!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
|
640 */ |