Mercurial > octave
annotate libinterp/corefcn/sighandlers.cc @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 362029cc0202 |
children | ed17822e7662 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30000
diff
changeset
|
3 // Copyright (C) 1993-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
1 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21609
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
1 | 28 #endif |
29 | |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
30 #include <csignal> |
2536 | 31 #include <cstdlib> |
32 | |
3503 | 33 #include <iostream> |
1344 | 34 #include <new> |
35 | |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
36 #if defined (OCTAVE_USE_WINDOWS_API) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
37 # define WIN32_LEAN_AND_MEAN |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
38 # include <windows.h> |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
39 #endif |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
40 |
24734
5d8c4cbc56d7
don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
41 #include "child-list.h" |
3281 | 42 #include "cmd-edit.h" |
5453 | 43 #include "oct-syscalls.h" |
4153 | 44 #include "quit.h" |
21938
da9b960b1b2d
use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents:
21936
diff
changeset
|
45 #include "signal-wrappers.h" |
3281 | 46 |
4185 | 47 #include "defun.h" |
1352 | 48 #include "error.h" |
10194 | 49 #include "input.h" |
24734
5d8c4cbc56d7
don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
50 #include "interpreter-private.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
51 #include "interpreter.h" |
1373 | 52 #include "load-save.h" |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
53 #include "octave.h" |
4294 | 54 #include "oct-map.h" |
2091 | 55 #include "pager.h" |
1 | 56 #include "sighandlers.h" |
4787 | 57 #include "sysdep.h" |
1 | 58 #include "utils.h" |
5794 | 59 #include "variables.h" |
1 | 60 |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
61 OCTAVE_NAMESPACE_BEGIN |
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
62 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
63 // 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
|
64 // 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
|
65 int pipe_handler_error_count = 0; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
66 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
67 // TRUE means we can be interrupted. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
68 bool can_interrupt = false; |
1 | 69 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
70 // 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
|
71 bool Vdebug_on_interrupt = false; |
1 | 72 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
73 // 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
|
74 // 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
|
75 // 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
|
76 static bool Vsighup_dumps_octave_core = true; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
77 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
78 // 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
|
79 static bool Vsigquit_dumps_octave_core = true; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
80 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
81 // 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
|
82 static bool Vsigterm_dumps_octave_core = true; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
83 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
84 // 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
|
85 static bool *signals_caught = nullptr; |
4185 | 86 |
23096
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
87 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
|
88 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
|
89 { |
23101
86376c04cb66
generate signal name from number when needed in signal handler functions
John W. Eaton <jwe@octave.org>
parents:
23096
diff
changeset
|
90 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
|
91 << 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
|
92 << " -- 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
|
93 |
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
94 if (save_vars) |
30000
362029cc0202
* load-save.h (dump_octave_core): Deprecate function. Change all uses.
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
95 { |
362029cc0202
* load-save.h (dump_octave_core): Deprecate function. Change all uses.
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
96 load_save_system& load_save_sys |
362029cc0202
* load-save.h (dump_octave_core): Deprecate function. Change all uses.
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
97 = __get_load_save_system__ ("my_friendly_exit"); |
362029cc0202
* load-save.h (dump_octave_core): Deprecate function. Change all uses.
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
98 |
362029cc0202
* load-save.h (dump_octave_core): Deprecate function. Change all uses.
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
99 load_save_sys.dump_octave_core (); |
362029cc0202
* load-save.h (dump_octave_core): Deprecate function. Change all uses.
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
100 } |
23096
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
101 |
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
102 sysdep_cleanup (); |
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
103 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
104 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
|
105 } |
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
106 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
107 // 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
|
108 // we have caught. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
109 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
110 void |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
111 respond_to_pending_signals (void) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
112 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
113 // 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
|
114 // linearly through the list. |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
115 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
116 // Interrupt signals are currently handled separately. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
117 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
118 static int sigint; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
119 static const bool have_sigint |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
120 = octave_get_sig_number ("SIGINT", &sigint); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
121 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
122 static int sigbreak; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
123 static const bool have_sigbreak |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
124 = octave_get_sig_number ("SIGBREAK", &sigbreak); |
24520
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 // Termination signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
127 |
23096
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
128 static int sighup; |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
129 static const bool have_sighup |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
130 = octave_get_sig_number ("SIGHUP", &sighup); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
131 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
132 static int sigquit; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
133 static const bool have_sigquit |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
134 = octave_get_sig_number ("SIGQUIT", &sigquit); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
135 |
23096
b7a24a734c37
defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
136 static int sigterm; |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
137 static const bool have_sigterm |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
138 = octave_get_sig_number ("SIGTERM", &sigterm); |
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 // Alarm 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 sigalrm; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
143 static const bool have_sigalrm |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
144 = octave_get_sig_number ("SIGALRM", &sigalrm); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
145 |
24525 | 146 static int sigvtalrm; |
147 static const bool have_sigvtalrm | |
148 = octave_get_sig_number ("SIGVTALRM", &sigvtalrm); | |
149 | |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
150 // I/O signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
151 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
152 static int sigio; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
153 static const bool have_sigio |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
154 = octave_get_sig_number ("SIGIO", &sigio); |
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 siglost; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
157 static const bool have_siglost |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
158 = octave_get_sig_number ("SIGLOST", &siglost); |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
159 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
160 static int sigpipe; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
161 static const bool have_sigpipe |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
162 = octave_get_sig_number ("SIGPIPE", &sigpipe); |
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 // Job control 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 sigchld; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
167 static const bool have_sigchld |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
168 = octave_get_sig_number ("SIGCHLD", &sigchld); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
169 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
170 static int sigcld; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
171 static const bool have_sigcld |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
172 = octave_get_sig_number ("SIGCLD", &sigcld); |
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 // Resource limit 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 sigxcpu; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
177 static const bool have_sigxcpu |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
178 = octave_get_sig_number ("SIGXCPU", &sigxcpu); |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
179 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
180 static int sigxfsz; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
181 static const bool have_sigxfsz |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
182 = octave_get_sig_number ("SIGXFSZ", &sigxfsz); |
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 // User signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
185 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
186 static int sigusr1; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
187 static const bool have_sigusr1 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
188 = octave_get_sig_number ("SIGUSR1", &sigusr1); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
189 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
190 static int sigusr2; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
191 static const bool have_sigusr2 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
192 = octave_get_sig_number ("SIGUSR2", &sigusr2); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
193 |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25284
diff
changeset
|
194 child_list& kids = __get_child_list__ ("respond_to_pending_signals"); |
24734
5d8c4cbc56d7
don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
195 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
196 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
|
197 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
198 if (signals_caught[sig]) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
199 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
200 signals_caught[sig] = false; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
201 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
202 if ((have_sigchld && sig == sigchld) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
203 || (have_sigcld && sig == sigcld)) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
204 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
205 // FIXME: should we block or ignore? |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
206 volatile interrupt_handler saved_interrupt_handler |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
207 = ignore_interrupts (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
208 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
209 void *context = octave_block_child (); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
210 |
24734
5d8c4cbc56d7
don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
211 kids.wait (); |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
212 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
213 set_interrupt_handler (saved_interrupt_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
214 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
215 octave_unblock_child (context); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
216 |
24734
5d8c4cbc56d7
don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
217 kids.reap (); |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
218 } |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
219 else if (have_sigpipe && sig == sigpipe) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
220 { |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
221 std::cerr << "warning: broken pipe" << std::endl; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
222 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
223 // Don't loop forever on account of this. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
224 // 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
|
225 // useful now? |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
226 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
227 if (pipe_handler_error_count++ > 100 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
228 && octave_interrupt_state >= 0) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
229 octave_interrupt_state++; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
230 } |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
231 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
|
232 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
|
233 else if (have_sigquit && sig == sigquit) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
234 my_friendly_exit (sigquit, Vsigquit_dumps_octave_core); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
235 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
|
236 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
|
237 else if ((have_sigalrm && sig == sigalrm) |
24525 | 238 || (have_sigvtalrm && sig == sigvtalrm) |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
239 || (have_sigio && sig == sigio) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
240 || (have_siglost && sig == siglost) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
241 || (have_sigxcpu && sig == sigxcpu) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
242 || (have_sigxfsz && sig == sigxfsz) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
243 || (have_sigusr1 && sig == sigusr1) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
244 || (have_sigusr2 && sig == sigusr2)) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
245 std::cerr << "warning: ignoring signal: " |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
246 << octave_strsignal_wrapper (sig) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
247 << std::endl; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
248 else if ((have_sigint && sig == sigint) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
249 || (have_sigbreak && sig == sigbreak)) |
25284
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
250 ; // Handled separately; do nothing. |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
251 else |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
252 std::cerr << "warning: ignoring unexpected signal: " |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
253 << octave_strsignal_wrapper (sig) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
254 << std::endl; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
255 } |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
256 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
257 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
258 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
259 sig_handler * |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
260 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
|
261 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
262 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
|
263 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
264 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
265 sig_handler * |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
266 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
|
267 bool restart_syscalls) |
22051
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 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
|
270 restart_syscalls); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
271 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
272 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
273 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
274 generic_sig_handler (int sig) |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
275 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
276 // 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
|
277 // 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
|
278 // how it accesses global objects. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
279 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
280 octave_signal_caught = 1; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
281 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
282 signals_caught[sig] = true; |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
283 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
284 static int sigint; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
285 static const bool have_sigint |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
286 = octave_get_sig_number ("SIGINT", &sigint); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
287 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
288 static int sigbreak; |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
289 static const bool have_sigbreak |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
290 = octave_get_sig_number ("SIGBREAK", &sigbreak); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
291 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
292 if ((have_sigint && sig == sigint) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
293 || (have_sigbreak && sig == sigbreak)) |
25284
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
294 { |
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
295 if (! octave_initialized) |
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
296 exit (1); |
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
297 |
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
298 if (can_interrupt) |
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
299 { |
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
300 octave_signal_caught = 1; |
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
301 octave_interrupt_state++; |
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
302 } |
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
303 } |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
304 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
305 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
306 static void |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
307 deadly_sig_handler (int sig) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
308 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
309 std::cerr << "fatal: caught signal " |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
310 << octave_strsignal_wrapper (sig) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
311 << " -- stopping myself..." << std::endl; |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
312 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
313 octave_set_default_signal_handler (sig); |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
314 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
315 octave_raise_wrapper (sig); |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
316 } |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
317 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
318 static void |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
319 fpe_sig_handler (int) |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
320 { |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
321 // 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
|
322 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
323 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
|
324 } |
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 |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
327 catch_interrupts (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
328 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
329 interrupt_handler retval; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
330 |
25284
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
331 retval.int_handler = set_signal_handler ("SIGINT", generic_sig_handler); |
78fb24bdd8bb
unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
332 retval.brk_handler = set_signal_handler ("SIGBREAK", generic_sig_handler); |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
333 |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
334 return retval; |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
335 } |
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
336 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
337 interrupt_handler |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
338 ignore_interrupts (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
339 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
340 interrupt_handler retval; |
17958
1adf3710bb68
Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17861
diff
changeset
|
341 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
342 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
|
343 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
|
344 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
345 return retval; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
346 } |
11555
f359cfc6e24d
sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
347 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
348 interrupt_handler |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
349 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
|
350 bool restart_syscalls) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
351 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
352 interrupt_handler retval; |
5142 | 353 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
354 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
|
355 restart_syscalls); |
5142 | 356 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
357 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
|
358 restart_syscalls); |
2536 | 359 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
360 return retval; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
361 } |
5451 | 362 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
363 // Install all the handlers for the signals we might care about. |
1373 | 364 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
365 void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
366 install_signal_handlers (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
367 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
368 if (! signals_caught) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
369 signals_caught = new bool [octave_num_signals ()]; |
5451 | 370 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
371 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
|
372 signals_caught[i] = false; |
3162 | 373 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
374 // Interrupt signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
375 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
376 catch_interrupts (); |
5144 | 377 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
378 // 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
|
379 // us. |
1446 | 380 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
381 set_signal_handler ("SIGABRT", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
382 set_signal_handler ("SIGBUS", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
383 set_signal_handler ("SIGEMT", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
384 set_signal_handler ("SIGILL", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
385 // SIGIOT is normally another name for SIGABRT. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
386 set_signal_handler ("SIGIOT", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
387 set_signal_handler ("SIGSEGV", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
388 set_signal_handler ("SIGSYS", deadly_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
389 set_signal_handler ("SIGTRAP", deadly_sig_handler); |
1230 | 390 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
391 // Handle SIGFPE separately. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
392 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
393 set_signal_handler ("SIGFPE", fpe_sig_handler); |
3281 | 394 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
395 // 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
|
396 // the program. |
4172 | 397 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
398 // Termination signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
399 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
400 set_signal_handler ("SIGHUP", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
401 set_signal_handler ("SIGQUIT", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
402 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
|
403 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
404 // Alarm signals. |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
405 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
406 set_signal_handler ("SIGALRM", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
407 set_signal_handler ("SIGVTALRM", generic_sig_handler); |
4793 | 408 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
409 // I/O signals. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
410 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
411 set_signal_handler ("SIGLOST", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
412 set_signal_handler ("SIGPIPE", generic_sig_handler); |
4787 | 413 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
414 // 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
|
415 // processes. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
416 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
417 set_signal_handler ("SIGCHLD", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
418 set_signal_handler ("SIGCLD", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
419 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
420 // Resource limit signals. |
5451 | 421 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
422 // 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
|
423 // signal? |
1 | 424 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
425 set_signal_handler ("SIGXCPU", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
426 set_signal_handler ("SIGXFSZ", generic_sig_handler); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
427 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
428 // User signals. |
2554 | 429 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
430 set_signal_handler ("SIGUSR1", generic_sig_handler); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
431 set_signal_handler ("SIGUSR2", generic_sig_handler); |
2705 | 432 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
433 // This does nothing on Windows systems. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
434 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
|
435 } |
635 | 436 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
437 static void |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
438 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
|
439 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
440 int signum; |
21941
1d23b75cbcd1
hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
441 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
442 // The names in the struct do not include the leading "SIG" prefix. |
1 | 443 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
444 if (octave_get_sig_number (signame, &signum)) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
445 m.assign (&signame[3], signum); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
446 } |
3174 | 447 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
448 static octave_scalar_map |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
449 make_sig_struct (void) |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
450 { |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
451 octave_scalar_map m; |
3174 | 452 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
453 set_sig_struct_field (m, "SIGABRT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
454 set_sig_struct_field (m, "SIGALRM"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
455 set_sig_struct_field (m, "SIGBUS"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
456 set_sig_struct_field (m, "SIGCHLD"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
457 set_sig_struct_field (m, "SIGCLD"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
458 set_sig_struct_field (m, "SIGCONT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
459 set_sig_struct_field (m, "SIGEMT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
460 set_sig_struct_field (m, "SIGFPE"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
461 set_sig_struct_field (m, "SIGHUP"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
462 set_sig_struct_field (m, "SIGILL"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
463 set_sig_struct_field (m, "SIGINFO"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
464 set_sig_struct_field (m, "SIGINT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
465 set_sig_struct_field (m, "SIGIO"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
466 set_sig_struct_field (m, "SIGIOT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
467 set_sig_struct_field (m, "SIGKILL"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
468 set_sig_struct_field (m, "SIGLOST"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
469 set_sig_struct_field (m, "SIGPIPE"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
470 set_sig_struct_field (m, "SIGPOLL"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
471 set_sig_struct_field (m, "SIGPROF"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
472 set_sig_struct_field (m, "SIGPWR"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
473 set_sig_struct_field (m, "SIGQUIT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
474 set_sig_struct_field (m, "SIGSEGV"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
475 set_sig_struct_field (m, "SIGSTKFLT"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
476 set_sig_struct_field (m, "SIGSTOP"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
477 set_sig_struct_field (m, "SIGSYS"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
478 set_sig_struct_field (m, "SIGTERM"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
479 set_sig_struct_field (m, "SIGTRAP"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
480 set_sig_struct_field (m, "SIGTSTP"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
481 set_sig_struct_field (m, "SIGTTIN"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
482 set_sig_struct_field (m, "SIGTTOU"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
483 set_sig_struct_field (m, "SIGUNUSED"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
484 set_sig_struct_field (m, "SIGURG"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
485 set_sig_struct_field (m, "SIGUSR1"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
486 set_sig_struct_field (m, "SIGUSR2"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
487 set_sig_struct_field (m, "SIGVTALRM"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
488 set_sig_struct_field (m, "SIGWINCH"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
489 set_sig_struct_field (m, "SIGXCPU"); |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
490 set_sig_struct_field (m, "SIGXFSZ"); |
4294 | 491 |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
492 return m; |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
493 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
494 |
5780 | 495 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
|
496 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
|
497 @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
|
498 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
|
499 @end deftypefn */) |
5780 | 500 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
501 if (args.length () != 0) |
5823 | 502 print_usage (); |
5780 | 503 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
504 static octave_scalar_map m = make_sig_struct (); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
505 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
506 return ovl (m); |
5780 | 507 } |
508 | |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
509 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
510 %!assert (isstruct (SIG ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
511 %!assert (! isempty (SIG ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
512 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14338
diff
changeset
|
513 %!error SIG (1) |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
514 */ |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
515 |
5794 | 516 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
|
517 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
|
518 @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
|
519 @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
|
520 @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
|
521 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
|
522 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
|
523 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
|
524 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
525 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
|
526 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
|
527 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
528 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
|
529 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
|
530 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
|
531 @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
|
532 @end deftypefn */) |
4449 | 533 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
534 return set_internal_variable (Vdebug_on_interrupt, args, nargout, |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
535 "debug_on_interrupt"); |
4449 | 536 } |
537 | |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
538 /* |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
539 %!test |
12832 | 540 %! orig_val = debug_on_interrupt (); |
541 %! old_val = debug_on_interrupt (! orig_val); | |
542 %! assert (orig_val, old_val); | |
543 %! assert (debug_on_interrupt (), ! orig_val); | |
544 %! debug_on_interrupt (orig_val); | |
545 %! 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
|
546 |
28930
2883b3d08b7e
maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
547 %!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
|
548 */ |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
549 |
5794 | 550 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
|
551 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
|
552 @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
|
553 @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
|
554 @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
|
555 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
|
556 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
|
557 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
|
558 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
559 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
|
560 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
|
561 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
|
562 @end deftypefn */) |
4185 | 563 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
564 return set_internal_variable (Vsighup_dumps_octave_core, |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
565 args, nargout, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
566 "sighup_dumps_octave_core"); |
5794 | 567 } |
4294 | 568 |
12827
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
569 /* |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
570 %!test |
12832 | 571 %! orig_val = sighup_dumps_octave_core (); |
572 %! old_val = sighup_dumps_octave_core (! orig_val); | |
573 %! assert (orig_val, old_val); | |
574 %! assert (sighup_dumps_octave_core (), ! orig_val); | |
575 %! sighup_dumps_octave_core (orig_val); | |
576 %! 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
|
577 |
28930
2883b3d08b7e
maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
578 %!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
|
579 */ |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
580 |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
581 DEFUN (sigquit_dumps_octave_core, args, nargout, |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
582 doc: /* -*- texinfo -*- |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
583 @deftypefn {} {@var{val} =} sigquit_dumps_octave_core () |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
584 @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
|
585 @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
|
586 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
|
587 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
|
588 receives a quit signal. |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
589 |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
590 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
|
591 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
|
592 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
|
593 @end deftypefn */) |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
594 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
595 return set_internal_variable (Vsigquit_dumps_octave_core, |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
596 args, nargout, |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
597 "sigquit_dumps_octave_core"); |
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 /* |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
601 %!test |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
602 %! orig_val = sigquit_dumps_octave_core (); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
603 %! old_val = sigquit_dumps_octave_core (! orig_val); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
604 %! assert (orig_val, old_val); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
605 %! assert (sigquit_dumps_octave_core (), ! orig_val); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
606 %! sigquit_dumps_octave_core (orig_val); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
607 %! assert (sigquit_dumps_octave_core (), orig_val); |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
608 |
28930
2883b3d08b7e
maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
609 %!error sigquit_dumps_octave_core (1, 2) |
24520
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
610 */ |
c5c11b07598a
refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents:
24118
diff
changeset
|
611 |
5794 | 612 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
|
613 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
|
614 @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
|
615 @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
|
616 @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
|
617 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
|
618 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
|
619 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
|
620 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
621 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
|
622 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
|
623 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
|
624 @end deftypefn */) |
5794 | 625 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
626 return set_internal_variable (Vsigterm_dumps_octave_core, |
22051
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
627 args, nargout, |
6db928d06b07
move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22049
diff
changeset
|
628 "sigterm_dumps_octave_core"); |
4185 | 629 } |
12827
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 /* |
8c6d71520920
codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
632 %!test |
12832 | 633 %! orig_val = sigterm_dumps_octave_core (); |
634 %! old_val = sigterm_dumps_octave_core (! orig_val); | |
635 %! assert (orig_val, old_val); | |
636 %! assert (sigterm_dumps_octave_core (), ! orig_val); | |
637 %! sigterm_dumps_octave_core (orig_val); | |
638 %! 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
|
639 |
28930
2883b3d08b7e
maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
640 %!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
|
641 */ |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
642 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
643 OCTAVE_NAMESPACE_END |