annotate libinterp/corefcn/sighandlers.cc @ 19069:afab3a2f57e7

doc: Update docstring for exist(). * variables.cc (Fexist): Update documentation string.
author Rik <rik@octave.org>
date Sun, 29 Jun 2014 12:58:22 -0700
parents 9cfba3616503
children 4197fc428c7d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17569
diff changeset
3 Copyright (C) 1993-2013 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
10 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
19 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 1
diff changeset
23 #ifdef HAVE_CONFIG_H
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
24 #include <config.h>
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
27 #include <cstdlib>
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
28
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3343
diff changeset
29 #include <iostream>
1344
c2ca372d3279 [project @ 1995-09-04 00:50:16 by jwe]
jwe
parents: 1343
diff changeset
30 #include <new>
c2ca372d3279 [project @ 1995-09-04 00:50:16 by jwe]
jwe
parents: 1343
diff changeset
31
834
44ce29d8cb7b [project @ 1994-10-19 18:17:44 by jwe]
jwe
parents: 635
diff changeset
32 #include <sys/types.h>
44ce29d8cb7b [project @ 1994-10-19 18:17:44 by jwe]
jwe
parents: 635
diff changeset
33 #include <unistd.h>
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
34
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
35 #include "cmd-edit.h"
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5451
diff changeset
36 #include "oct-syscalls.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4092
diff changeset
37 #include "quit.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
38 #include "singleton-cleanup.h"
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
39
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
40 #include "debug.h"
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
41 #include "defun.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
42 #include "error.h"
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
43 #include "input.h"
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
44 #include "load-save.h"
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
45 #include "oct-map.h"
2091
60f5e1c20815 [project @ 1996-04-28 08:32:39 by jwe]
jwe
parents: 2016
diff changeset
46 #include "pager.h"
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
47 #include "pt-bp.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
48 #include "pt-eval.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
49 #include "sighandlers.h"
4787
02c748eb2ddc [project @ 2004-02-18 21:20:26 by jwe]
jwe
parents: 4675
diff changeset
50 #include "sysdep.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
51 #include "syswait.h"
2091
60f5e1c20815 [project @ 1996-04-28 08:32:39 by jwe]
jwe
parents: 2016
diff changeset
52 #include "toplev.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
53 #include "utils.h"
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
54 #include "variables.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
55
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
56 // Nonzero means we have already printed a message for this series of
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
57 // SIGPIPES. We assume that the writer will eventually give up.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
58 int pipe_handler_error_count = 0;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
59
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2931
diff changeset
60 // TRUE means we can be interrupted.
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2931
diff changeset
61 bool can_interrupt = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
62
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
63 // TRUE means we should try to enter the debugger on SIGINT.
15595
6e780fb15c14 Make Vdebug_on_interrupt not be static
Max Brister <max@2bass.com>
parents: 15195
diff changeset
64 bool Vdebug_on_interrupt = false;
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
65
14889
577df411e0c7 rename octave-core file to octave-workspace
John W. Eaton <jwe@octave.org>
parents: 14861
diff changeset
66 // Allow users to avoid writing octave-workspace for SIGHUP (sent by
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
67 // closing gnome-terminal, for example). Note that this variable has
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
68 // no effect if Vcrash_dumps_octave_core is FALSE.
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
69 static bool Vsighup_dumps_octave_core = true;
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
70
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
71 // Similar to Vsighup_dumps_octave_core, but for SIGTERM signal.
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
72 static bool Vsigterm_dumps_octave_core = true;
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
73
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
74 // List of signals we have caught since last call to octave_signal_handler.
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
75 static bool octave_signals_caught[NSIG];
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
76
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
77 // Forward declaration.
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
78 static void user_abort (const char *sig_name, int sig_number);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
79
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
80 #if defined (__WIN32__) && ! defined (__CYGWIN__)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
81
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
82 #define WIN32_LEAN_AND_MEAN
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
83 #include <windows.h>
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
84
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
85 class
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
86 w32_interrupt_manager
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
87 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
88 public:
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
89 ~w32_interrupt_manager (void)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
90 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
91 if (thread)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
92 CloseHandle (thread);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
93 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
94
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
95 static bool init (void) { return instance_ok (); }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
96
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
97 static void octave_jump_to_enclosing_context (void)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
98 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
99 if (instance_ok ())
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
100 instance->do_octave_jump_to_enclosing_context ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
101 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
102
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
103 static void user_abort (const char *sig_name, int sig_number)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
104 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
105 if (instance_ok ())
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
106 instance->do_user_abort (sig_name, sig_number);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
107 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
108
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
109 static void raise_sigint (void)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
110 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
111 if (instance_ok ())
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
112 instance->do_raise_sigint ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
113 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
114
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
115 private:
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
116 w32_interrupt_manager (void)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
117 : thread (0), thread_id (0)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
118 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
119 thread_id = GetCurrentThreadId ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
120
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
121 DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
122 GetCurrentProcess (), &thread, 0, FALSE,
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
123 DUPLICATE_SAME_ACCESS);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
124 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
125
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
126 static void octave_jump_to_enclosing_context_sync (void)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
127 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
128 #ifdef _MSC_VER
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
129 _fpreset ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
130 #endif
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
131 ::octave_jump_to_enclosing_context ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
132 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
133
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
134 void do_octave_jump_to_enclosing_context (void)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
135 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
136 bool is_interrupt_thread = (GetCurrentThreadId () == thread_id);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
137
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
138 if (is_interrupt_thread)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
139 octave_jump_to_enclosing_context_sync ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
140 else
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
141 {
18529
9cfba3616503 allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents: 17958
diff changeset
142 // 64-bit Windows does not appear to have threadContext.Eip.
9cfba3616503 allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents: 17958
diff changeset
143 // Something else must be done here to allow interrupts to
9cfba3616503 allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents: 17958
diff changeset
144 // properly work across threads.
9cfba3616503 allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents: 17958
diff changeset
145
9cfba3616503 allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents: 17958
diff changeset
146 #if ! (defined (__MINGW64__) || defined (_WIN64))
9cfba3616503 allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents: 17958
diff changeset
147
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
148 CONTEXT threadContext;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
149
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
150 SuspendThread (thread);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
151 threadContext.ContextFlags = CONTEXT_CONTROL;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
152 GetThreadContext (thread, &threadContext);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
153 threadContext.Eip = (DWORD) octave_jump_to_enclosing_context_sync;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
154 SetThreadContext (thread, &threadContext);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
155 ResumeThread (thread);
18529
9cfba3616503 allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents: 17958
diff changeset
156 #endif
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
157 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
158 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
159
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
160 void do_user_abort (const char *sig_name, int sig_number)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
161 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
162 bool is_interrupt_thread = (GetCurrentThreadId () == thread_id);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
163
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
164 if (is_interrupt_thread)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
165 ::user_abort (sig_name, sig_number);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
166 else
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
167 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
168 SuspendThread (thread);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
169 ::user_abort (sig_name, sig_number);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
170 ResumeThread (thread);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
171 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
172 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
173
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
174 void do_raise_sigint (void)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
175 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
176 bool is_interrupt_thread = (GetCurrentThreadId () == thread_id);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
177
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
178 if (is_interrupt_thread)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
179 ::raise (SIGINT);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
180 else
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
181 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
182 SuspendThread (thread);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
183 ::raise (SIGINT);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
184 ResumeThread (thread);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
185 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
186 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
187
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
188 static bool instance_ok (void)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
189 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
190 bool retval = true;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
191
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
192 if (! instance)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
193 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
194 instance = new w32_interrupt_manager ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
195
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
196 if (instance)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
197 singleton_cleanup_list::add (cleanup_instance);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
198 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
199
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
200 if (! instance)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
201 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
202 ::error ("unable to create w32_interrupt_manager");
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
203
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
204 retval = false;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
205 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
206
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
207 return retval;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
208 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
209
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
210 static void cleanup_instance (void) { delete instance; instance = 0; }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
211
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
212 private:
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
213 // A handle to the thread that is running the octave interpreter.
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
214 HANDLE thread;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
215
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
216 // The ID of the thread that is running the octave interpreter.
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
217 DWORD thread_id;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
218
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
219 static w32_interrupt_manager* instance;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
220 };
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
221
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
222 w32_interrupt_manager* w32_interrupt_manager::instance = 0;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
223
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
224 void w32_raise_sigint (void)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
225 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
226 w32_interrupt_manager::raise_sigint ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
227 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
228
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
229 #endif
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
230
11525
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
231 // Signal handler return type.
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
232 #ifndef BADSIG
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
233 #define BADSIG (void (*)(int))-1
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
234 #endif
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
235
14338
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
236 // The following is a workaround for an apparent bug in GCC 4.1.2 and
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
237 // possibly earlier versions. See Octave bug report #30685 for details.
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
238 #if defined (__GNUC__)
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
239 # if ! (__GNUC__ > 4 \
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
240 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 1 \
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
241 || (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ > 2))))
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
242 # undef GNULIB_NAMESPACE
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
243 # define GNULIB_NAMESPACE
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
244 # warning "disabling GNULIB_NAMESPACE for signal functions -- consider upgrading to a current version of GCC"
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
245 # endif
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
246 #endif
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
247
11525
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
248 #define BLOCK_SIGNAL(sig, nvar, ovar) \
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
249 do \
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
250 { \
14338
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
251 GNULIB_NAMESPACE::sigemptyset (&nvar); \
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
252 GNULIB_NAMESPACE::sigaddset (&nvar, sig); \
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
253 GNULIB_NAMESPACE::sigemptyset (&ovar); \
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
254 GNULIB_NAMESPACE::sigprocmask (SIG_BLOCK, &nvar, &ovar); \
11525
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
255 } \
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
256 while (0)
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
257
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
258 #if !defined (SIGCHLD) && defined (SIGCLD)
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
259 #define SIGCHLD SIGCLD
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
260 #endif
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
261
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
262 #define BLOCK_CHILD(nvar, ovar) BLOCK_SIGNAL (SIGCHLD, nvar, ovar)
14338
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
263 #define UNBLOCK_CHILD(ovar) GNULIB_NAMESPACE::sigprocmask (SIG_SETMASK, &ovar, 0)
11525
ab231f944252 avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
264
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
265 // Called from octave_quit () to actually do something about the signals
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
266 // we have caught.
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
267
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
268 void
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
269 octave_signal_handler (void)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
270 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
271 // The list of signals is relatively short, so we will just go
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
272 // linearly through the list.
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
273
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
274 for (int i = 0; i < NSIG; i++)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
275 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
276 if (octave_signals_caught[i])
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
277 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
278 octave_signals_caught[i] = false;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
279
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
280 switch (i)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
281 {
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
282 #ifdef SIGCHLD
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
283 case SIGCHLD:
11555
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
284 {
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
285 volatile octave_interrupt_handler saved_interrupt_handler
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
286 = octave_ignore_interrupts ();
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
287
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
288 sigset_t set, oset;
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
289
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
290 BLOCK_CHILD (set, oset);
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
291
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
292 octave_child_list::wait ();
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
293
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
294 octave_set_interrupt_handler (saved_interrupt_handler);
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
295
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
296 UNBLOCK_CHILD (oset);
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
297
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
298 octave_child_list::reap ();
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
299 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
300 break;
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
301 #endif
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
302
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
303 case SIGFPE:
14893
55d0f8d70fe9 shorten signal warnings
John W. Eaton <jwe@octave.org>
parents: 14889
diff changeset
304 std::cerr << "warning: floating point exception" << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
305 break;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
306
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
307 #ifdef SIGPIPE
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
308 case SIGPIPE:
14893
55d0f8d70fe9 shorten signal warnings
John W. Eaton <jwe@octave.org>
parents: 14889
diff changeset
309 std::cerr << "warning: broken pipe" << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
310 break;
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
311 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
312 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
313 }
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
314 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
315 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
316
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
317 static void
4787
02c748eb2ddc [project @ 2004-02-18 21:20:26 by jwe]
jwe
parents: 4675
diff changeset
318 my_friendly_exit (const char *sig_name, int sig_number,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
319 bool save_vars = true)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
320 {
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
321 static bool been_there_done_that = false;
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
322
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
323 if (been_there_done_that)
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
324 {
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
325 #if defined (SIGABRT)
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
326 octave_set_signal_handler (SIGABRT, SIG_DFL);
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
327 #endif
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
328
3644
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3566
diff changeset
329 std::cerr << "panic: attempted clean up apparently failed -- aborting...\n";
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
330
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
331 MINGW_SIGNAL_CLEANUP ();
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
332
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
333 abort ();
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
334 }
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
335 else
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
336 {
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
337 been_there_done_that = true;
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
338
3644
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3566
diff changeset
339 std::cerr << "panic: " << sig_name << " -- stopping myself...\n";
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
340
4787
02c748eb2ddc [project @ 2004-02-18 21:20:26 by jwe]
jwe
parents: 4675
diff changeset
341 if (save_vars)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
342 dump_octave_core ();
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
343
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3018
diff changeset
344 if (sig_number < 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
345 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
346 MINGW_SIGNAL_CLEANUP ();
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
347
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
348 exit (1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
349 }
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3018
diff changeset
350 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
351 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
352 octave_set_signal_handler (sig_number, SIG_DFL);
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3018
diff changeset
353
14338
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
354 GNULIB_NAMESPACE::raise (sig_number);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
355 }
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
356 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
357 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
358
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
359 sig_handler *
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5453
diff changeset
360 octave_set_signal_handler (int sig, sig_handler *handler,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
361 bool restart_syscalls)
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
362 {
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
363 struct sigaction act, oact;
5144
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
364
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
365 act.sa_handler = handler;
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
366 act.sa_flags = 0;
5144
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
367
10344
65974373505a Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
368 #if defined (SIGALRM)
5144
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
369 if (sig == SIGALRM)
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
370 {
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
371 #if defined (SA_INTERRUPT)
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
372 act.sa_flags |= SA_INTERRUPT;
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
373 #endif
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
374 }
10344
65974373505a Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
375 #endif
5144
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
376 #if defined (SA_RESTART)
10344
65974373505a Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
377 #if defined (SIGALRM)
65974373505a Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
378 else
65974373505a Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
379 #endif
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17787
diff changeset
380 // FIXME: Do we also need to explicitly disable SA_RESTART?
10344
65974373505a Do not use SIGALRM unconditinally.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
381 if (restart_syscalls)
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5453
diff changeset
382 act.sa_flags |= SA_RESTART;
5144
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
383 #endif
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
384
14338
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
385 GNULIB_NAMESPACE::sigemptyset (&act.sa_mask);
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
386 GNULIB_NAMESPACE::sigemptyset (&oact.sa_mask);
5144
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
387
14338
1ecfba4427ff workaround for apparent bug in GCC 4.1.2 (bug #30685)
John W. Eaton <jwe@octave.org>
parents: 14154
diff changeset
388 GNULIB_NAMESPACE::sigaction (sig, &act, &oact);
5144
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
389
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
390 return oact.sa_handler;
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
391 }
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
392
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
393 static void
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
394 generic_sig_handler (int sig)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
395 {
5844
034cdbd34c0a [project @ 2006-06-07 15:38:58 by jwe]
jwe
parents: 5823
diff changeset
396 my_friendly_exit (strsignal (sig), sig);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
397 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
398
2091
60f5e1c20815 [project @ 1996-04-28 08:32:39 by jwe]
jwe
parents: 2016
diff changeset
399 // Handle SIGCHLD.
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
400
4064
b4fa31442a78 [project @ 2002-09-26 21:10:45 by jwe]
jwe
parents: 3644
diff changeset
401 #ifdef SIGCHLD
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
402 static void
2092
a938192ff632 [project @ 1996-04-28 08:36:22 by jwe]
jwe
parents: 2091
diff changeset
403 sigchld_handler (int /* sig */)
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
404 {
11555
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
405 octave_signal_caught = 1;
2626
b35a5cd8107f [project @ 1997-01-27 01:41:30 by jwe]
jwe
parents: 2600
diff changeset
406
11555
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
407 octave_signals_caught[SIGCHLD] = true;
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
408 }
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14443
diff changeset
409 #endif /* defined (SIGCHLD) */
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
410
4064
b4fa31442a78 [project @ 2002-09-26 21:10:45 by jwe]
jwe
parents: 3644
diff changeset
411 #ifdef SIGFPE
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
412 #if defined (__alpha__)
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
413 static void
1488
89c587478067 [project @ 1995-09-26 22:49:48 by jwe]
jwe
parents: 1446
diff changeset
414 sigfpe_handler (int /* sig */)
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
415 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
416 if (can_interrupt && octave_interrupt_state >= 0)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
417 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
418 octave_signal_caught = 1;
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
419
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
420 octave_signals_caught[SIGFPE] = true;
4182
4d1d7c51205c [project @ 2002-11-15 20:33:47 by jwe]
jwe
parents: 4181
diff changeset
421
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
422 octave_interrupt_state++;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
423 }
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
424 }
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14443
diff changeset
425 #endif /* defined (__alpha__) */
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14443
diff changeset
426 #endif /* defined (SIGFPE) */
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
427
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
428 #if defined (SIGHUP) || defined (SIGTERM)
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
429 static void
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
430 sig_hup_or_term_handler (int sig)
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
431 {
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
432 switch (sig)
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
433 {
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
434 #if defined (SIGHUP)
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
435 case SIGHUP:
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
436 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
437 if (Vsighup_dumps_octave_core)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
438 dump_octave_core ();
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
439 }
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
440 break;
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
441 #endif
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
442
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
443 #if defined (SIGTERM)
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
444 case SIGTERM:
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
445 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
446 if (Vsigterm_dumps_octave_core)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
447 dump_octave_core ();
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
448 }
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
449 break;
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
450 #endif
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
451
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
452 default:
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
453 break;
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
454 }
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
455
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
456 clean_up_and_exit (0);
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
457 }
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
458 #endif
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
459
3343
466d7a1cac01 [project @ 1999-11-05 19:34:29 by jwe]
jwe
parents: 3281
diff changeset
460 #if 0
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
461 #if defined (SIGWINCH)
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
462 static void
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
463 sigwinch_handler (int /* sig */)
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
464 {
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
465 command_editor::resize_terminal ();
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
466 }
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
467 #endif
3343
466d7a1cac01 [project @ 1999-11-05 19:34:29 by jwe]
jwe
parents: 3281
diff changeset
468 #endif
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
469
635
5338832d2cf6 [project @ 1994-08-23 17:57:20 by jwe]
jwe
parents: 529
diff changeset
470 // Handle SIGINT by restarting the parser (see octave.cc).
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
471 //
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
472 // This also has to work for SIGBREAK (on systems that have it), so we
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
473 // use the value of sig, instead of just assuming that it is called
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
474 // for SIGINT only.
635
5338832d2cf6 [project @ 1994-08-23 17:57:20 by jwe]
jwe
parents: 529
diff changeset
475
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
476 static void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
477 user_abort (const char *sig_name, int sig_number)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
478 {
4172
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4153
diff changeset
479 if (! octave_initialized)
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4153
diff changeset
480 exit (1);
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4153
diff changeset
481
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
482 if (can_interrupt)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
483 {
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
484 if (Vdebug_on_interrupt)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
485 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
486 if (! octave_debug_on_interrupt_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
487 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
488 tree_evaluator::debug_mode = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
489 octave_debug_on_interrupt_state = true;
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
490
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
491 return;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
492 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
493 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
494 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
495 // Clear the flag and do normal interrupt stuff.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
496
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
497 tree_evaluator::debug_mode
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
498 = bp_table::have_breakpoints () || Vdebugging;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
499 octave_debug_on_interrupt_state = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
500 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
501 }
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
502
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4092
diff changeset
503 if (octave_interrupt_immediately)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
504 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
505 if (octave_interrupt_state == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
506 octave_interrupt_state = 1;
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
507
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
508 #if defined (__WIN32__) && ! defined (__CYGWIN__)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
509 w32_interrupt_manager::octave_jump_to_enclosing_context ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
510 #else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
511 octave_jump_to_enclosing_context ();
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
512 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
513 }
4429
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4294
diff changeset
514 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
515 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
516 // If we are already cleaning up from a previous interrupt,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
517 // take note of the fact that another interrupt signal has
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
518 // arrived.
4793
a62215ab8a03 [project @ 2004-02-20 20:59:34 by jwe]
jwe
parents: 4791
diff changeset
519
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
520 if (octave_interrupt_state < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
521 octave_interrupt_state = 0;
4793
a62215ab8a03 [project @ 2004-02-20 20:59:34 by jwe]
jwe
parents: 4791
diff changeset
522
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
523 octave_signal_caught = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
524 octave_interrupt_state++;
4787
02c748eb2ddc [project @ 2004-02-18 21:20:26 by jwe]
jwe
parents: 4675
diff changeset
525
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
526 if (interactive && octave_interrupt_state == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
527 std::cerr << "Press Control-C again to abort." << std::endl;
4787
02c748eb2ddc [project @ 2004-02-18 21:20:26 by jwe]
jwe
parents: 4675
diff changeset
528
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
529 if (octave_interrupt_state >= 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
530 my_friendly_exit (sig_name, sig_number, true);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
531 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
532 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
533
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
534 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
535
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
536 static void
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
537 sigint_handler (int sig)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
538 {
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
539 #if defined (__WIN32__) && ! defined (__CYGWIN__)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
540 w32_interrupt_manager::user_abort (strsignal (sig), sig);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
541 #else
5844
034cdbd34c0a [project @ 2006-06-07 15:38:58 by jwe]
jwe
parents: 5823
diff changeset
542 user_abort (strsignal (sig), sig);
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
543 #endif
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
544 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
545
4064
b4fa31442a78 [project @ 2002-09-26 21:10:45 by jwe]
jwe
parents: 3644
diff changeset
546 #ifdef SIGPIPE
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
547 static void
1488
89c587478067 [project @ 1995-09-26 22:49:48 by jwe]
jwe
parents: 1446
diff changeset
548 sigpipe_handler (int /* sig */)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
549 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
550 octave_signal_caught = 1;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
551
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
552 octave_signals_caught[SIGPIPE] = true;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
553
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
554 // Don't loop forever on account of this.
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
555
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
556 if (pipe_handler_error_count++ > 100 && octave_interrupt_state >= 0)
4787
02c748eb2ddc [project @ 2004-02-18 21:20:26 by jwe]
jwe
parents: 4675
diff changeset
557 octave_interrupt_state++;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
558 }
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14443
diff changeset
559 #endif /* defined (SIGPIPE) */
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
560
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
561 octave_interrupt_handler
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
562 octave_catch_interrupts (void)
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
563 {
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
564 octave_interrupt_handler retval;
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
565
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
566 #if defined (__WIN32__) && ! defined (__CYGWIN__)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
567 w32_interrupt_manager::init ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
568 #endif
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
569
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
570 #ifdef SIGINT
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
571 retval.int_handler = octave_set_signal_handler (SIGINT, sigint_handler);
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
572 #endif
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
573
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
574 #ifdef SIGBREAK
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
575 retval.brk_handler = octave_set_signal_handler (SIGBREAK, sigint_handler);
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
576 #endif
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
577
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
578 return retval;
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
579 }
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
580
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
581 octave_interrupt_handler
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
582 octave_ignore_interrupts (void)
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
583 {
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
584 octave_interrupt_handler retval;
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
585
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
586 #if defined (__WIN32__) && ! defined (__CYGWIN__)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
587 w32_interrupt_manager::init ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
588 #endif
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
589
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
590 #ifdef SIGINT
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
591 retval.int_handler = octave_set_signal_handler (SIGINT, SIG_IGN);
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
592 #endif
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
593
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
594 #ifdef SIGBREAK
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
595 retval.brk_handler = octave_set_signal_handler (SIGBREAK, SIG_IGN);
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
596 #endif
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
597
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
598 return retval;
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
599 }
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
600
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
601 octave_interrupt_handler
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5453
diff changeset
602 octave_set_interrupt_handler (const volatile octave_interrupt_handler& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
603 bool restart_syscalls)
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
604 {
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
605 octave_interrupt_handler retval;
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
606
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
607 #if defined (__WIN32__) && ! defined (__CYGWIN__)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
608 w32_interrupt_manager::init ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
609 #endif
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
610
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
611 #ifdef SIGINT
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5453
diff changeset
612 retval.int_handler = octave_set_signal_handler (SIGINT, h.int_handler,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
613 restart_syscalls);
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
614 #endif
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
615
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
616 #ifdef SIGBREAK
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5453
diff changeset
617 retval.brk_handler = octave_set_signal_handler (SIGBREAK, h.brk_handler,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
618 restart_syscalls);
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
619 #endif
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
620
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
621 return retval;
1651
e846e361a265 [project @ 1995-12-20 06:59:12 by jwe]
jwe
parents: 1618
diff changeset
622 }
e846e361a265 [project @ 1995-12-20 06:59:12 by jwe]
jwe
parents: 1618
diff changeset
623
635
5338832d2cf6 [project @ 1994-08-23 17:57:20 by jwe]
jwe
parents: 529
diff changeset
624 // Install all the handlers for the signals we might care about.
5338832d2cf6 [project @ 1994-08-23 17:57:20 by jwe]
jwe
parents: 529
diff changeset
625
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
626 void
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
627 install_signal_handlers (void)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
628 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
629 for (int i = 0; i < NSIG; i++)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
630 octave_signals_caught[i] = false;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
631
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
632 octave_catch_interrupts ();
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
633
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
634 #ifdef SIGABRT
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
635 octave_set_signal_handler (SIGABRT, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
636 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
637
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
638 #ifdef SIGALRM
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
639 octave_set_signal_handler (SIGALRM, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
640 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
641
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
642 #ifdef SIGBUS
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
643 octave_set_signal_handler (SIGBUS, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
644 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
645
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
646 #ifdef SIGCHLD
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
647 octave_set_signal_handler (SIGCHLD, sigchld_handler);
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
648 #endif
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
649
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
650 // SIGCLD
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
651 // SIGCONT
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
652
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
653 #ifdef SIGEMT
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
654 octave_set_signal_handler (SIGEMT, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
655 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
656
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
657 #ifdef SIGFPE
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
658 #if defined (__alpha__)
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
659 octave_set_signal_handler (SIGFPE, sigfpe_handler);
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
660 #else
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
661 octave_set_signal_handler (SIGFPE, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
662 #endif
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
663 #endif
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
664
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
665 #ifdef SIGHUP
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
666 octave_set_signal_handler (SIGHUP, sig_hup_or_term_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
667 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
668
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
669 #ifdef SIGILL
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
670 octave_set_signal_handler (SIGILL, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
671 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
672
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
673 // SIGINFO
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
674 // SIGINT
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
675
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
676 #ifdef SIGIOT
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
677 octave_set_signal_handler (SIGIOT, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
678 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
679
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
680 #ifdef SIGLOST
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
681 octave_set_signal_handler (SIGLOST, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
682 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
683
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
684 #ifdef SIGPIPE
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
685 octave_set_signal_handler (SIGPIPE, sigpipe_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
686 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
687
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
688 #ifdef SIGPOLL
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
689 octave_set_signal_handler (SIGPOLL, SIG_IGN);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
690 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
691
5866
f9ac7ebf0e19 [project @ 2006-06-28 16:05:22 by jwe]
jwe
parents: 5844
diff changeset
692 // SIGPROF
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
693 // SIGPWR
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
694
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
695 #ifdef SIGQUIT
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
696 octave_set_signal_handler (SIGQUIT, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
697 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
698
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
699 #ifdef SIGSEGV
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
700 octave_set_signal_handler (SIGSEGV, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
701 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
702
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
703 // SIGSTOP
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
704
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
705 #ifdef SIGSYS
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
706 octave_set_signal_handler (SIGSYS, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
707 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
708
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
709 #ifdef SIGTERM
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
710 octave_set_signal_handler (SIGTERM, sig_hup_or_term_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
711 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
712
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
713 #ifdef SIGTRAP
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
714 octave_set_signal_handler (SIGTRAP, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
715 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
716
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
717 // SIGTSTP
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
718 // SIGTTIN
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
719 // SIGTTOU
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
720 // SIGURG
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
721
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
722 #ifdef SIGUSR1
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
723 octave_set_signal_handler (SIGUSR1, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
724 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
725
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
726 #ifdef SIGUSR2
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
727 octave_set_signal_handler (SIGUSR2, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
728 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
729
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
730 #ifdef SIGVTALRM
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
731 octave_set_signal_handler (SIGVTALRM, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
732 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
733
895
05654cdcfc95 [project @ 1994-11-09 15:30:06 by jwe]
jwe
parents: 886
diff changeset
734 #ifdef SIGIO
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
735 octave_set_signal_handler (SIGIO, SIG_IGN);
895
05654cdcfc95 [project @ 1994-11-09 15:30:06 by jwe]
jwe
parents: 886
diff changeset
736 #endif
05654cdcfc95 [project @ 1994-11-09 15:30:06 by jwe]
jwe
parents: 886
diff changeset
737
3343
466d7a1cac01 [project @ 1999-11-05 19:34:29 by jwe]
jwe
parents: 3281
diff changeset
738 #if 0
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
739 #ifdef SIGWINCH
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
740 octave_set_signal_handler (SIGWINCH, sigwinch_handler);
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
741 #endif
3343
466d7a1cac01 [project @ 1999-11-05 19:34:29 by jwe]
jwe
parents: 3281
diff changeset
742 #endif
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
743
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
744 #ifdef SIGXCPU
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
745 octave_set_signal_handler (SIGXCPU, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
746 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
747
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
748 #ifdef SIGXFSZ
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
749 octave_set_signal_handler (SIGXFSZ, generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
750 #endif
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
751
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
752 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
753
11066
e678346a47d9 toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
754 static octave_scalar_map
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
755 make_sig_struct (void)
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
756 {
11066
e678346a47d9 toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
757 octave_scalar_map m;
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
758
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
759 #ifdef SIGABRT
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
760 m.assign ("ABRT", SIGABRT);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
761 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
762
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
763 #ifdef SIGALRM
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
764 m.assign ("ALRM", SIGALRM);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
765 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
766
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
767 #ifdef SIGBUS
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
768 m.assign ("BUS", SIGBUS);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
769 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
770
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
771 #ifdef SIGCHLD
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
772 m.assign ("CHLD", SIGCHLD);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
773 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
774
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
775 #ifdef SIGCLD
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
776 m.assign ("CLD", SIGCLD);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
777 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
778
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
779 #ifdef SIGCONT
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
780 m.assign ("CONT", SIGCONT);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
781 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
782
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
783 #ifdef SIGEMT
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
784 m.assign ("EMT", SIGEMT);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
785 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
786
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
787 #ifdef SIGFPE
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
788 m.assign ("FPE", SIGFPE);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
789 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
790
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
791 #ifdef SIGHUP
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
792 m.assign ("HUP", SIGHUP);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
793 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
794
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
795 #ifdef SIGILL
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
796 m.assign ("ILL", SIGILL);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
797 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
798
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
799 #ifdef SIGINFO
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
800 m.assign ("INFO", SIGINFO);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
801 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
802
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
803 #ifdef SIGINT
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
804 m.assign ("INT", SIGINT);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
805 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
806
16706
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
807 #ifdef SIGIO
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
808 m.assign ("IO", SIGIO);
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
809 #endif
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
810
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
811 #ifdef SIGIOT
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
812 m.assign ("IOT", SIGIOT);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
813 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
814
16706
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
815 #ifdef SIGKILL
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
816 m.assign ("KILL", SIGKILL);
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
817 #endif
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
818
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
819 #ifdef SIGLOST
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
820 m.assign ("LOST", SIGLOST);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
821 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
822
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
823 #ifdef SIGPIPE
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
824 m.assign ("PIPE", SIGPIPE);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
825 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
826
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
827 #ifdef SIGPOLL
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
828 m.assign ("POLL", SIGPOLL);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
829 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
830
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
831 #ifdef SIGPROF
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
832 m.assign ("PROF", SIGPROF);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
833 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
834
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
835 #ifdef SIGPWR
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
836 m.assign ("PWR", SIGPWR);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
837 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
838
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
839 #ifdef SIGQUIT
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
840 m.assign ("QUIT", SIGQUIT);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
841 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
842
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
843 #ifdef SIGSEGV
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
844 m.assign ("SEGV", SIGSEGV);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
845 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
846
16706
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
847 #ifdef SIGSTKFLT
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
848 m.assign ("STKFLT", SIGSTKFLT);
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
849 #endif
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
850
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
851 #ifdef SIGSTOP
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
852 m.assign ("STOP", SIGSTOP);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
853 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
854
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
855 #ifdef SIGSYS
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
856 m.assign ("SYS", SIGSYS);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
857 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
858
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
859 #ifdef SIGTERM
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
860 m.assign ("TERM", SIGTERM);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
861 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
862
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
863 #ifdef SIGTRAP
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
864 m.assign ("TRAP", SIGTRAP);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
865 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
866
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
867 #ifdef SIGTSTP
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
868 m.assign ("TSTP", SIGTSTP);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
869 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
870
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
871 #ifdef SIGTTIN
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
872 m.assign ("TTIN", SIGTTIN);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
873 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
874
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
875 #ifdef SIGTTOU
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
876 m.assign ("TTOU", SIGTTOU);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
877 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
878
16706
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
879 #ifdef SIGUNUSED
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
880 m.assign ("UNUSED", SIGUNUSED);
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
881 #endif
736dca8371ee include more signals in SIG function (bug #39089)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16404
diff changeset
882
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
883 #ifdef SIGURG
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
884 m.assign ("URG", SIGURG);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
885 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
886
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
887 #ifdef SIGUSR1
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
888 m.assign ("USR1", SIGUSR1);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
889 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
890
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
891 #ifdef SIGUSR2
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
892 m.assign ("USR2", SIGUSR2);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
893 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
894
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
895 #ifdef SIGVTALRM
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
896 m.assign ("VTALRM", SIGVTALRM);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
897 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
898
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
899 #ifdef SIGWINCH
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
900 m.assign ("WINCH", SIGWINCH);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
901 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
902
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
903 #ifdef SIGXCPU
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
904 m.assign ("XCPU", SIGXCPU);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
905 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
906
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
907 #ifdef SIGXFSZ
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4449
diff changeset
908 m.assign ("XFSZ", SIGXFSZ);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
909 #endif
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
910
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
911 return m;
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
912 }
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
913
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
914 octave_child_list::octave_child_list_rep *octave_child_list::instance = 0;
5128
2c4b08ace285 [project @ 2005-02-04 21:41:38 by jwe]
jwe
parents: 4793
diff changeset
915
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
916 bool
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
917 octave_child_list::instance_ok (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
918 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
919 bool retval = true;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
920
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
921 if (! instance)
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
922 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
923 instance = new octave_child_list_rep ();
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
924
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
925 if (instance)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
926 singleton_cleanup_list::add (cleanup_instance);
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
927 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
928
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
929 if (! instance)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
930 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
931 ::error ("unable to create child list object!");
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
932
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
933 retval = false;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
934 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
935
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
936 return retval;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
937 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
938
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
939 void
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
940 octave_child_list::insert (pid_t pid, octave_child::child_event_handler f)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
941 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
942 if (instance_ok ())
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
943 instance->insert (pid, f);
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
944 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
945
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
946 void
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
947 octave_child_list::reap (void)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
948 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
949 if (instance_ok ())
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
950 instance->reap ();
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
951 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
952
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
953 bool
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
954 octave_child_list::wait (void)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
955 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
956 return (instance_ok ()) ? instance->wait () : false;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
957 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
958
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
959 class pid_equal
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
960 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
961 public:
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
962
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
963 pid_equal (pid_t v) : val (v) { }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
964
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
965 bool operator () (const octave_child& oc) const { return oc.pid == val; }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
966
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
967 private:
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
968
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
969 pid_t val;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
970 };
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
971
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
972 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
973 octave_child_list::remove (pid_t pid)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
974 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
975 if (instance_ok ())
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
976 instance->remove_if (pid_equal (pid));
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
977 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
978
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
979 #define OCL_REP octave_child_list::octave_child_list_rep
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
980
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
981 void
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
982 OCL_REP::insert (pid_t pid, octave_child::child_event_handler f)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
983 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
984 append (octave_child (pid, f));
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
985 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
986
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
987 void
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
988 OCL_REP::reap (void)
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
989 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
990 // Mark the record for PID invalid.
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
991
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
992 for (iterator p = begin (); p != end (); p++)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
993 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
994 // The call to the octave_child::child_event_handler might
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
995 // invalidate the iterator (for example, by calling
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
996 // octave_child_list::remove), so we increment the iterator
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
997 // here.
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
998
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
999 octave_child& oc = *p;
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
1000
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1001 if (oc.have_status)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1002 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1003 oc.have_status = 0;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1004
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1005 octave_child::child_event_handler f = oc.handler;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1006
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1007 if (f && f (oc.pid, oc.status))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1008 oc.pid = -1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1009 }
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
1010 }
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
1011
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1012 remove_if (pid_equal (-1));
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
1013 }
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
1014
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1015 // Wait on our children and record any changes in their status.
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1016
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1017 bool
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1018 OCL_REP::wait (void)
2210
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
1019 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1020 bool retval = false;
2210
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
1021
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1022 for (iterator p = begin (); p != end (); p++)
2210
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
1023 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1024 octave_child& oc = *p;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1025
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1026 pid_t pid = oc.pid;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1027
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1028 if (pid > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1029 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1030 int status;
2210
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
1031
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1032 if (octave_syscalls::waitpid (pid, &status, WNOHANG) > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1033 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1034 oc.have_status = 1;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1035
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1036 oc.status = status;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1037
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1038 retval = true;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1039
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1040 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1041 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
1042 }
2210
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
1043 }
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
1044
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
1045 return retval;
2210
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
1046 }
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
1047
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1048 DEFUN (SIG, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17778
diff changeset
1049 "-*- texinfo -*-\n\
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1050 @deftypefn {Built-in Function} {} SIG ()\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1051 Return a structure containing Unix signal names and their defined values.\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1052 @end deftypefn")
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1053 {
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1054 octave_value retval;
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1055
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1056 if (args.length () == 0)
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1057 {
11066
e678346a47d9 toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1058 static octave_scalar_map m = make_sig_struct ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1059
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1060 retval = m;
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1061 }
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1062 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
1063 print_usage ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1064
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1065 return retval;
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1066 }
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1067
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1068 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
1069 %!assert (isstruct (SIG ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
1070 %!assert (! isempty (SIG ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
1071
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
1072 %!error SIG (1)
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1073 */
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1074
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1075 DEFUN (debug_on_interrupt, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17778
diff changeset
1076 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10411
diff changeset
1077 @deftypefn {Built-in Function} {@var{val} =} debug_on_interrupt ()\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1078 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_interrupt (@var{new_val})\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 12832
diff changeset
1079 @deftypefnx {Built-in Function} {} debug_on_interrupt (@var{new_val}, \"local\")\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1080 Query or set the internal variable that controls whether Octave will try\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1081 to enter debugging mode when it receives an interrupt signal (typically\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1082 generated with @kbd{C-c}). If a second interrupt signal is received\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1083 before reaching the debugging mode, a normal interrupt will occur.\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 12832
diff changeset
1084 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1085 When called from inside a function with the @qcode{\"local\"} option, the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1086 variable is changed locally for the function and any subroutines it calls. \n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1087 The original variable value is restored when exiting the function.\n\
15573
63d024333bee doc: Add seealso links between debug_on_XXX functions (bug #37576)
Rik <rik@octave.org>
parents: 14338
diff changeset
1088 @seealso{debug_on_error, debug_on_warning}\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1089 @end deftypefn")
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
1090 {
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1091 return SET_INTERNAL_VARIABLE (debug_on_interrupt);
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
1092 }
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
1093
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1094 /*
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1095 %!test
12832
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1096 %! orig_val = debug_on_interrupt ();
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1097 %! old_val = debug_on_interrupt (! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1098 %! assert (orig_val, old_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1099 %! assert (debug_on_interrupt (), ! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1100 %! debug_on_interrupt (orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1101 %! 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
1102
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
1103 %!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
1104 */
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1105
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1106 DEFUN (sighup_dumps_octave_core, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17778
diff changeset
1107 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10411
diff changeset
1108 @deftypefn {Built-in Function} {@var{val} =} sighup_dumps_octave_core ()\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1109 @deftypefnx {Built-in Function} {@var{old_val} =} sighup_dumps_octave_core (@var{new_val})\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 12832
diff changeset
1110 @deftypefnx {Built-in Function} {} sighup_dumps_octave_core (@var{new_val}, \"local\")\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1111 Query or set the internal variable that controls whether Octave tries\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1112 to save all current variables to the file @file{octave-workspace} if it\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1113 receives a hangup signal.\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 12832
diff changeset
1114 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1115 When called from inside a function with the @qcode{\"local\"} option, the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1116 variable is changed locally for the function and any subroutines it calls. \n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1117 The original variable value is restored when exiting the function.\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1118 @end deftypefn")
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
1119 {
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1120 return SET_INTERNAL_VARIABLE (sighup_dumps_octave_core);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1121 }
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
1122
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1123 /*
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1124 %!test
12832
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1125 %! orig_val = sighup_dumps_octave_core ();
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1126 %! old_val = sighup_dumps_octave_core (! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1127 %! assert (orig_val, old_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1128 %! assert (sighup_dumps_octave_core (), ! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1129 %! sighup_dumps_octave_core (orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1130 %! 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
1131
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
1132 %!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
1133 */
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1134
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1135 DEFUN (sigterm_dumps_octave_core, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17778
diff changeset
1136 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10411
diff changeset
1137 @deftypefn {Built-in Function} {@var{val} =} sigterm_dumps_octave_core ()\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1138 @deftypefnx {Built-in Function} {@var{old_val} =} sigterm_dumps_octave_core (@var{new_val})\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 12832
diff changeset
1139 @deftypefnx {Built-in Function} {} sigterm_dumps_octave_core (@var{new_val}, \"local\")\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1140 Query or set the internal variable that controls whether Octave tries\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1141 to save all current variables to the file @file{octave-workspace} if it\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1142 receives a terminate signal.\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 12832
diff changeset
1143 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1144 When called from inside a function with the @qcode{\"local\"} option, the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1145 variable is changed locally for the function and any subroutines it calls. \n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16892
diff changeset
1146 The original variable value is restored when exiting the function.\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1147 @end deftypefn")
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1148 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1149 return SET_INTERNAL_VARIABLE (sigterm_dumps_octave_core);
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
1150 }
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1151
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1152 /*
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1153 %!test
12832
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1154 %! orig_val = sigterm_dumps_octave_core ();
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1155 %! old_val = sigterm_dumps_octave_core (! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1156 %! assert (orig_val, old_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1157 %! assert (sigterm_dumps_octave_core (), ! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1158 %! sigterm_dumps_octave_core (orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
1159 %! 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
1160
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
1161 %!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
1162 */