annotate libinterp/corefcn/sighandlers.cc @ 33617:ec2635a02328 bytecode-interpreter tip

maint: Merge default to bytecode-interpreter.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 21 May 2024 18:29:03 +0200
parents ebc26cef3096
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 //
32632
2e484f9f1f18 maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31846
diff changeset
3 // Copyright (C) 1993-2024 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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
28 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
29
31846
5f0b8101234e Remove several race conditions with signal handler (bug #61370).
Reinhard Resch <r_resch@a1.net>
parents: 31771
diff changeset
30 #include <atomic>
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
31 #include <csignal>
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
32 #include <cstdlib>
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
33
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3343
diff changeset
34 #include <iostream>
1344
c2ca372d3279 [project @ 1995-09-04 00:50:16 by jwe]
jwe
parents: 1343
diff changeset
35 #include <new>
c2ca372d3279 [project @ 1995-09-04 00:50:16 by jwe]
jwe
parents: 1343
diff changeset
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
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
43 #include "cmd-edit.h"
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5451
diff changeset
44 #include "oct-syscalls.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4092
diff changeset
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
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
47
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
48 #include "defun.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
49 #include "error.h"
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
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
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
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
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
55 #include "oct-map.h"
2091
60f5e1c20815 [project @ 1996-04-28 08:32:39 by jwe]
jwe
parents: 2016
diff changeset
56 #include "pager.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
57 #include "sighandlers.h"
4787
02c748eb2ddc [project @ 2004-02-18 21:20:26 by jwe]
jwe
parents: 4675
diff changeset
58 #include "sysdep.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
59 #include "utils.h"
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
60 #include "variables.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
61
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31105
diff changeset
62 OCTAVE_BEGIN_NAMESPACE(octave)
29960
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
63
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
64 // Nonzero means we have already printed a message for this series of
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
65 // SIGPIPES. We assume that the writer will eventually give up.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
66 int pipe_handler_error_count = 0;
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
67
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
68 // TRUE means we can be interrupted.
31846
5f0b8101234e Remove several race conditions with signal handler (bug #61370).
Reinhard Resch <r_resch@a1.net>
parents: 31771
diff changeset
69 std::atomic<bool> can_interrupt{false};
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
70
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
71 // TRUE means we should try to enter the debugger on SIGINT.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
72 bool Vdebug_on_interrupt = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
73
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
74 // Allow users to avoid writing octave-workspace for SIGHUP (sent by
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
75 // closing gnome-terminal, for example). Note that this variable has
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
76 // no effect if Vcrash_dumps_octave_core is FALSE.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
77 static bool Vsighup_dumps_octave_core = true;
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
78
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
79 // Similar to Vsighup_dumps_octave_core, but for SIGQUIT signal.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
80 static bool Vsigquit_dumps_octave_core = true;
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
81
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
82 // Similar to Vsighup_dumps_octave_core, but for SIGTERM signal.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
83 static bool Vsigterm_dumps_octave_core = true;
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
84
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
85 // List of signals we have caught since last call to signal_handler.
31846
5f0b8101234e Remove several race conditions with signal handler (bug #61370).
Reinhard Resch <r_resch@a1.net>
parents: 31771
diff changeset
86 static std::atomic<bool> *signals_caught = nullptr;
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
87
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
88 static void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
89 my_friendly_exit (int sig, bool save_vars = true)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
90 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
91 std::cerr << "fatal: caught signal "
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
92 << octave_strsignal_wrapper (sig)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
93 << " -- stopping myself..." << std::endl;
23096
b7a24a734c37 defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents: 23084
diff changeset
94
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
95 if (save_vars)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
96 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
97 load_save_system& load_save_sys = __get_load_save_system__ ();
30000
362029cc0202 * load-save.h (dump_octave_core): Deprecate function. Change all uses.
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
98
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
99 load_save_sys.dump_octave_core ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
102 sysdep_cleanup ();
23096
b7a24a734c37 defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents: 23084
diff changeset
103
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
104 throw exit_exception (1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
105 }
23096
b7a24a734c37 defer SIGHUP and SIGTERM actions until octave_quit is called
John W. Eaton <jwe@octave.org>
parents: 23084
diff changeset
106
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
107 // Called from octave_quit () to actually do something about the signals
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
108 // we have caught.
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
109
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
110 void
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
111 respond_to_pending_signals ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
112 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
113 // The list of signals is relatively short, so we will just go
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
114 // linearly through the list.
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
115
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
116 // Interrupt signals are currently handled separately.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
117
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
118 static int sigint;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
119 static const bool have_sigint
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
120 = octave_get_sig_number ("SIGINT", &sigint);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
121
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
122 static int sigbreak;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
123 static const bool have_sigbreak
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
126 // Termination signals.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
127
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
128 static int sighup;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
129 static const bool have_sighup
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
130 = octave_get_sig_number ("SIGHUP", &sighup);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
131
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
132 static int sigquit;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
133 static const bool have_sigquit
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
134 = octave_get_sig_number ("SIGQUIT", &sigquit);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
135
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
136 static int sigterm;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
137 static const bool have_sigterm
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
138 = octave_get_sig_number ("SIGTERM", &sigterm);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
139
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
140 // Alarm signals.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
141
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
142 static int sigalrm;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
143 static const bool have_sigalrm
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
144 = octave_get_sig_number ("SIGALRM", &sigalrm);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
145
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
146 static int sigvtalrm;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
147 static const bool have_sigvtalrm
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
148 = octave_get_sig_number ("SIGVTALRM", &sigvtalrm);
24525
a8eb8a734b9d tweaks to signal handlers
John W. Eaton <jwe@octave.org>
parents: 24520
diff changeset
149
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
150 // I/O signals.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
151
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
152 static int sigio;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
153 static const bool have_sigio
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
154 = octave_get_sig_number ("SIGIO", &sigio);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
155
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
156 static int siglost;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
157 static const bool have_siglost
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
160 static int sigpipe;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
161 static const bool have_sigpipe
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
162 = octave_get_sig_number ("SIGPIPE", &sigpipe);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
163
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
164 // Job control signals.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
165
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
166 static int sigchld;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
167 static const bool have_sigchld
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
168 = octave_get_sig_number ("SIGCHLD", &sigchld);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
169
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
170 static int sigcld;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
171 static const bool have_sigcld
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
172 = octave_get_sig_number ("SIGCLD", &sigcld);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
173
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
174 // Resource limit signals.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
175
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
176 static int sigxcpu;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
177 static const bool have_sigxcpu
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
180 static int sigxfsz;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
181 static const bool have_sigxfsz
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
182 = octave_get_sig_number ("SIGXFSZ", &sigxfsz);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
183
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
184 // User signals.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
185
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
186 static int sigusr1;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
187 static const bool have_sigusr1
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
188 = octave_get_sig_number ("SIGUSR1", &sigusr1);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
189
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
190 static int sigusr2;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
191 static const bool have_sigusr2
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
192 = octave_get_sig_number ("SIGUSR2", &sigusr2);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
193
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
194 child_list& kids = __get_child_list__ ();
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
195
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
196 for (int sig = 0; sig < octave_num_signals (); sig++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
197 {
31846
5f0b8101234e Remove several race conditions with signal handler (bug #61370).
Reinhard Resch <r_resch@a1.net>
parents: 31771
diff changeset
198 bool expected = true;
5f0b8101234e Remove several race conditions with signal handler (bug #61370).
Reinhard Resch <r_resch@a1.net>
parents: 31771
diff changeset
199
5f0b8101234e Remove several race conditions with signal handler (bug #61370).
Reinhard Resch <r_resch@a1.net>
parents: 31771
diff changeset
200 if (signals_caught[sig].compare_exchange_strong (expected, false))
31635
7d3467f8d713 Backed out changeset d9970470108a
John W. Eaton <jwe@octave.org>
parents: 31633
diff changeset
201 {
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
202 if ((have_sigchld && sig == sigchld)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
203 || (have_sigcld && sig == sigcld))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
204 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
205 // FIXME: should we block or ignore?
33041
ebc26cef3096 eliminate more obsolete volatile declarations
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
206 interrupt_handler saved_interrupt_handler = ignore_interrupts ();
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
207
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
208 void *context = octave_block_child ();
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
209
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
210 kids.wait ();
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
211
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
212 set_interrupt_handler (saved_interrupt_handler);
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
213
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
214 octave_unblock_child (context);
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
215
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
216 kids.reap ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
217 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
218 else if (have_sigpipe && sig == sigpipe)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
219 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
220 std::cerr << "warning: broken pipe" << std::endl;
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
221
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
222 // Don't loop forever on account of this.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
223 // FIXME: is this really needed? Does it do anything
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
224 // useful now?
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
225
31635
7d3467f8d713 Backed out changeset d9970470108a
John W. Eaton <jwe@octave.org>
parents: 31633
diff changeset
226 if (pipe_handler_error_count++ > 100
7d3467f8d713 Backed out changeset d9970470108a
John W. Eaton <jwe@octave.org>
parents: 31633
diff changeset
227 && octave_interrupt_state >= 0)
7d3467f8d713 Backed out changeset d9970470108a
John W. Eaton <jwe@octave.org>
parents: 31633
diff changeset
228 octave_interrupt_state++;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
229 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
230 else if (have_sighup && sig == sighup)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
231 my_friendly_exit (sighup, Vsighup_dumps_octave_core);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
232 else if (have_sigquit && sig == sigquit)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
233 my_friendly_exit (sigquit, Vsigquit_dumps_octave_core);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
234 else if (have_sigterm && sig == sigterm)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
235 my_friendly_exit (sigterm, Vsigterm_dumps_octave_core);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
236 else if ((have_sigalrm && sig == sigalrm)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
237 || (have_sigvtalrm && sig == sigvtalrm)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
238 || (have_sigio && sig == sigio)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
239 || (have_siglost && sig == siglost)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
240 || (have_sigxcpu && sig == sigxcpu)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
241 || (have_sigxfsz && sig == sigxfsz)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
242 || (have_sigusr1 && sig == sigusr1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
243 || (have_sigusr2 && sig == sigusr2))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
244 std::cerr << "warning: ignoring signal: "
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
245 << octave_strsignal_wrapper (sig)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
246 << std::endl;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
247 else if ((have_sigint && sig == sigint)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
248 || (have_sigbreak && sig == sigbreak))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
249 ; // Handled separately; do nothing.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
250 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
251 std::cerr << "warning: ignoring unexpected signal: "
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
252 << octave_strsignal_wrapper (sig)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
253 << std::endl;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
254 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
255 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
256 }
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
257
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
258 sig_handler *
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
259 set_signal_handler (int sig, sig_handler *handler, bool restart_syscalls)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
260 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
261 return octave_set_signal_handler_internal (sig, handler, restart_syscalls);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
262 }
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
263
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
264 sig_handler *
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
265 set_signal_handler (const char *signame, sig_handler *handler,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
266 bool restart_syscalls)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
267 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
268 return octave_set_signal_handler_by_name (signame, handler,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
269 restart_syscalls);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
270 }
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
271
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
272 static void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
273 generic_sig_handler (int sig)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
274 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
275 // FIXME: this function may execute in a separate signal handler or
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
276 // signal watcher thread so it should probably be more careful about
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
277 // how it accesses global objects.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
278
31846
5f0b8101234e Remove several race conditions with signal handler (bug #61370).
Reinhard Resch <r_resch@a1.net>
parents: 31771
diff changeset
279 octave_signal_caught = true;
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
280
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
281 signals_caught[sig] = true;
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
282
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
283 static int sigint;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
284 static const bool have_sigint
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
285 = octave_get_sig_number ("SIGINT", &sigint);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
286
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
287 static int sigbreak;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
288 static const bool have_sigbreak
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
289 = octave_get_sig_number ("SIGBREAK", &sigbreak);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
290
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
291 if ((have_sigint && sig == sigint)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
292 || (have_sigbreak && sig == sigbreak))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
293 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
294 if (! octave_initialized)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
295 exit (1);
25284
78fb24bdd8bb unblock async signals before executing subprocess (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
296
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
297 if (can_interrupt)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
298 {
31846
5f0b8101234e Remove several race conditions with signal handler (bug #61370).
Reinhard Resch <r_resch@a1.net>
parents: 31771
diff changeset
299 octave_signal_caught = true;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
300 octave_interrupt_state++;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
301 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
302 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
303 }
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
304
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
305 static void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
306 deadly_sig_handler (int sig)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
307 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
308 std::cerr << "fatal: caught signal "
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
309 << octave_strsignal_wrapper (sig)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
310 << " -- stopping myself..." << std::endl;
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
311
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
312 octave_set_default_signal_handler (sig);
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
313
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
314 octave_raise_wrapper (sig);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
315 }
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
316
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
317 static void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
318 fpe_sig_handler (int)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
319 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
320 // 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
321
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
322 std::cerr << "warning: floating point exception" << std::endl;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
323 }
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
324
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
325 interrupt_handler
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
326 catch_interrupts ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
327 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
328 interrupt_handler retval;
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
329
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
330 retval.int_handler = set_signal_handler ("SIGINT", generic_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
331 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
332
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
333 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
334 }
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
335
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
336 interrupt_handler
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
337 ignore_interrupts ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
338 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
339 interrupt_handler retval;
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
340
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
341 retval.int_handler = set_signal_handler ("SIGINT", SIG_IGN);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
342 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
343
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
344 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
345 }
11555
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
346
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
347 interrupt_handler
33041
ebc26cef3096 eliminate more obsolete volatile declarations
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
348 set_interrupt_handler (const interrupt_handler& h, bool restart_syscalls)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
349 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
350 interrupt_handler retval;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
351
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
352 retval.int_handler = set_signal_handler ("SIGINT", h.int_handler,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
353 restart_syscalls);
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
354
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
355 retval.brk_handler = set_signal_handler ("SIGBREAK", h.brk_handler,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
356 restart_syscalls);
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
357
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
358 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
359 }
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
360
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
361 // Install all the handlers for the signals we might care about.
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
362
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
363 void
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
364 install_signal_handlers ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
365 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
366 if (! signals_caught)
31846
5f0b8101234e Remove several race conditions with signal handler (bug #61370).
Reinhard Resch <r_resch@a1.net>
parents: 31771
diff changeset
367 signals_caught = new std::atomic<bool> [octave_num_signals ()];
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
368
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
369 for (int i = 0; i < octave_num_signals (); i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
370 signals_caught[i] = false;
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3018
diff changeset
371
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
372 // Interrupt signals.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
373
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
374 catch_interrupts ();
5144
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
375
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
376 // Program Error signals. These are most likely unrecoverable for
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
377 // us.
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
378
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
379 set_signal_handler ("SIGABRT", deadly_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
380 set_signal_handler ("SIGBUS", deadly_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
381 set_signal_handler ("SIGEMT", deadly_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
382 set_signal_handler ("SIGILL", deadly_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
383 // SIGIOT is normally another name for SIGABRT.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
384 set_signal_handler ("SIGIOT", deadly_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
385 set_signal_handler ("SIGSEGV", deadly_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
386 set_signal_handler ("SIGSYS", deadly_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
387 set_signal_handler ("SIGTRAP", deadly_sig_handler);
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
388
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
389 // Handle SIGFPE separately.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
390
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
391 set_signal_handler ("SIGFPE", fpe_sig_handler);
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
392
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
393 // Handle other signals for which the default action is to terminate
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
394 // the program.
4172
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4153
diff changeset
395
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
396 // Termination signals.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
397
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
398 set_signal_handler ("SIGHUP", generic_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
399 set_signal_handler ("SIGQUIT", generic_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
400 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
401
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
402 // Alarm signals.
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
403
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
404 set_signal_handler ("SIGALRM", generic_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
405 set_signal_handler ("SIGVTALRM", generic_sig_handler);
4793
a62215ab8a03 [project @ 2004-02-20 20:59:34 by jwe]
jwe
parents: 4791
diff changeset
406
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
407 // I/O signals.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
408
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
409 set_signal_handler ("SIGLOST", generic_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
410 set_signal_handler ("SIGPIPE", generic_sig_handler);
4787
02c748eb2ddc [project @ 2004-02-18 21:20:26 by jwe]
jwe
parents: 4675
diff changeset
411
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
412 // Job control signals. We only recognize signals about child
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
413 // processes.
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
414
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
415 set_signal_handler ("SIGCHLD", generic_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
416 set_signal_handler ("SIGCLD", generic_sig_handler);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
417
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
418 // Resource limit signals.
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
419
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
420 // FIXME: does it really make sense to try to handle the CPU limit
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
421 // signal?
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
422
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
423 set_signal_handler ("SIGXCPU", generic_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
424 set_signal_handler ("SIGXFSZ", generic_sig_handler);
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
425
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
426 // User signals.
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
427
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
428 set_signal_handler ("SIGUSR1", generic_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
429 set_signal_handler ("SIGUSR2", generic_sig_handler);
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
430
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
431 // This does nothing on Windows systems.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
432 octave_create_interrupt_watcher_thread (generic_sig_handler);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
433 }
635
5338832d2cf6 [project @ 1994-08-23 17:57:20 by jwe]
jwe
parents: 529
diff changeset
434
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
435 static void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
436 set_sig_struct_field (octave_scalar_map& m, const char *signame)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
437 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
438 int signum;
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
439
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
440 // The names in the struct do not include the leading "SIG" prefix.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
441
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
442 if (octave_get_sig_number (signame, &signum))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
443 m.assign (&signame[3], signum);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
444 }
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
445
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
446 static octave_scalar_map
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
447 make_sig_struct ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
448 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
449 octave_scalar_map m;
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
450
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
451 set_sig_struct_field (m, "SIGABRT");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
452 set_sig_struct_field (m, "SIGALRM");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
453 set_sig_struct_field (m, "SIGBUS");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
454 set_sig_struct_field (m, "SIGCHLD");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
455 set_sig_struct_field (m, "SIGCLD");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
456 set_sig_struct_field (m, "SIGCONT");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
457 set_sig_struct_field (m, "SIGEMT");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
458 set_sig_struct_field (m, "SIGFPE");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
459 set_sig_struct_field (m, "SIGHUP");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
460 set_sig_struct_field (m, "SIGILL");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
461 set_sig_struct_field (m, "SIGINFO");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
462 set_sig_struct_field (m, "SIGINT");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
463 set_sig_struct_field (m, "SIGIO");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
464 set_sig_struct_field (m, "SIGIOT");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
465 set_sig_struct_field (m, "SIGKILL");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
466 set_sig_struct_field (m, "SIGLOST");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
467 set_sig_struct_field (m, "SIGPIPE");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
468 set_sig_struct_field (m, "SIGPOLL");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
469 set_sig_struct_field (m, "SIGPROF");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
470 set_sig_struct_field (m, "SIGPWR");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
471 set_sig_struct_field (m, "SIGQUIT");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
472 set_sig_struct_field (m, "SIGSEGV");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
473 set_sig_struct_field (m, "SIGSTKFLT");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
474 set_sig_struct_field (m, "SIGSTOP");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
475 set_sig_struct_field (m, "SIGSYS");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
476 set_sig_struct_field (m, "SIGTERM");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
477 set_sig_struct_field (m, "SIGTRAP");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
478 set_sig_struct_field (m, "SIGTSTP");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
479 set_sig_struct_field (m, "SIGTTIN");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
480 set_sig_struct_field (m, "SIGTTOU");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
481 set_sig_struct_field (m, "SIGUNUSED");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
482 set_sig_struct_field (m, "SIGURG");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
483 set_sig_struct_field (m, "SIGUSR1");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
484 set_sig_struct_field (m, "SIGUSR2");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
485 set_sig_struct_field (m, "SIGVTALRM");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
486 set_sig_struct_field (m, "SIGWINCH");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
487 set_sig_struct_field (m, "SIGXCPU");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
488 set_sig_struct_field (m, "SIGXFSZ");
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
489
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
490 return m;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
491 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
492
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
493 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
494 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30588
diff changeset
495 @deftypefn {} {@var{S} =} SIG ()
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 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
497 @end deftypefn */)
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
498 {
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
499 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
500 print_usage ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
501
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
502 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
503
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
504 return ovl (m);
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
505 }
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
506
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
507 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
508 %!assert (isstruct (SIG ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
509 %!assert (! isempty (SIG ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
510
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
511 %!error SIG (1)
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
512 */
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
513
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
514 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
515 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
516 @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
517 @deftypefnx {} {@var{old_val} =} debug_on_interrupt (@var{new_val})
30588
ed17822e7662 doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents: 30564
diff changeset
518 @deftypefnx {} {@var{old_val} =} debug_on_interrupt (@var{new_val}, "local")
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
519 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
520 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
521 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
522
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
523 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
524 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
525
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
526 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
527 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
528 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
529 @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
530 @end deftypefn */)
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
531 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
532 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
533 "debug_on_interrupt");
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
534 }
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
535
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
536 /*
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
537 %!test
12832
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
538 %! orig_val = debug_on_interrupt ();
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
539 %! old_val = debug_on_interrupt (! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
540 %! assert (orig_val, old_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
541 %! assert (debug_on_interrupt (), ! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
542 %! debug_on_interrupt (orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
543 %! 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
544
28930
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 27923
diff changeset
545 %!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
546 */
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
547
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
548 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
549 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
550 @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
551 @deftypefnx {} {@var{old_val} =} sighup_dumps_octave_core (@var{new_val})
30588
ed17822e7662 doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents: 30564
diff changeset
552 @deftypefnx {} {@var{old_val} =} sighup_dumps_octave_core (@var{new_val}, "local")
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
553 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
554 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
555 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
556
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
557 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
558 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
559 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
560 @end deftypefn */)
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
561 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
562 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
563 args, nargout,
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
564 "sighup_dumps_octave_core");
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
565 }
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
566
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
567 /*
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
568 %!test
12832
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
569 %! orig_val = sighup_dumps_octave_core ();
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
570 %! old_val = sighup_dumps_octave_core (! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
571 %! assert (orig_val, old_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
572 %! assert (sighup_dumps_octave_core (), ! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
573 %! sighup_dumps_octave_core (orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
574 %! 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
575
28930
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 27923
diff changeset
576 %!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
577 */
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
578
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
579 DEFUN (sigquit_dumps_octave_core, args, nargout,
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
580 doc: /* -*- texinfo -*-
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
581 @deftypefn {} {@var{val} =} sigquit_dumps_octave_core ()
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
582 @deftypefnx {} {@var{old_val} =} sigquit_dumps_octave_core (@var{new_val})
30588
ed17822e7662 doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents: 30564
diff changeset
583 @deftypefnx {} {@var{old_val} =} sigquit_dumps_octave_core (@var{new_val}, "local")
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
584 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
585 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
586 receives a quit signal.
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
587
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
588 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
589 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
590 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
591 @end deftypefn */)
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
592 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
593 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
594 args, nargout,
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
595 "sigquit_dumps_octave_core");
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 /*
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
599 %!test
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
600 %! orig_val = sigquit_dumps_octave_core ();
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
601 %! old_val = sigquit_dumps_octave_core (! orig_val);
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
602 %! assert (orig_val, old_val);
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
603 %! assert (sigquit_dumps_octave_core (), ! orig_val);
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
604 %! sigquit_dumps_octave_core (orig_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
28930
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 27923
diff changeset
607 %!error sigquit_dumps_octave_core (1, 2)
24520
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
608 */
c5c11b07598a refactor signal handling (bug #52757)
John W. Eaton <jwe@octave.org>
parents: 24118
diff changeset
609
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
610 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
611 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
612 @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
613 @deftypefnx {} {@var{old_val} =} sigterm_dumps_octave_core (@var{new_val})
30588
ed17822e7662 doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents: 30564
diff changeset
614 @deftypefnx {} {@var{old_val} =} sigterm_dumps_octave_core (@var{new_val}, "local")
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
615 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
616 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
617 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
618
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
619 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
620 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
621 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
622 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
623 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
624 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
625 args, nargout,
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22049
diff changeset
626 "sigterm_dumps_octave_core");
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
627 }
12827
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 /*
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
630 %!test
12832
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
631 %! orig_val = sigterm_dumps_octave_core ();
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
632 %! old_val = sigterm_dumps_octave_core (! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
633 %! assert (orig_val, old_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
634 %! assert (sigterm_dumps_octave_core (), ! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
635 %! sigterm_dumps_octave_core (orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
636 %! 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
637
28930
2883b3d08b7e maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents: 27923
diff changeset
638 %!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
639 */
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
640
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31105
diff changeset
641 OCTAVE_END_NAMESPACE(octave)