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