annotate libinterp/corefcn/sighandlers.cc @ 21966:112b20240c87

move docstrings in C++ files out of C strings and into comments * __contourc__.cc, __dispatch__.cc, __dsearchn__.cc, __ichol__.cc, __ilu__.cc, __lin_interpn__.cc, __luinc__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc, betainc.cc, bitfcns.cc, bsxfun.cc, cellfun.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, defaults.cc, det.cc, dirfns.cc, dlmread.cc, dot.cc, eig.cc, ellipj.cc, error.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, graphics.cc, hash.cc, help.cc, hess.cc, hex2num.cc, input.cc, inv.cc, kron.cc, load-path.cc, load-save.cc, lookup.cc, ls-oct-text.cc, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mgorth.cc, nproc.cc, oct-hist.cc, octave-link.cc, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, profiler.cc, psi.cc, pt-jit.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, urlwrite.cc, utils.cc, variables.cc, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc, convhulln.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc, ov-base.cc, ov-bool-mat.cc, ov-cell.cc, ov-class.cc, ov-classdef.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-flt-re-mat.cc, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-range.cc, ov-re-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc, ov.cc, octave.cc, pt-arg-list.cc, pt-binop.cc, pt-eval.cc, pt-mat.cc, lex.ll, oct-parse.in.yy: Docstrings are now comments instead of C strings. * build-aux/mk-opts.pl: Emit docstrings as comments instead of C strings. * DASPK-opts.in, LSODE-opts.in: Don't quote " in docstring fragments. * builtins.h: Include builtin-defun-decls.h unconditionally. * defun.h (DEFUN, DEFUNX, DEFCONSTFUN): Simply emit declaration. (DEFALIAS): Always expand to nothing. * defun-dld.h: No special macro expansions for MAKE_BUILTINS. (DEFUN_DLD): Use FORWARD_DECLARE_FUN. (DEFUNX_DLD): Use FORWARD_DECLARE_FUNX. * defun-int.h: No special macro expansions for MAKE_BUILTINS. (FORWARD_DECLARE_FUN, FORWARD_DECLARE_FUNX): New macros. (DEFINE_FUN_INSTALLER_FUN): If compiling an Octave source file, pass "external-doc" to DEFINE_FUNX_INSTALLER_FUN. (DEFUN_INTERNAL, DEFCONSTFUN_INTERNAL, DEFUNX_INTERNAL, DEFALIAS_INTERNAL): Delete. * common.mk (move_if_change_rule): New macro. (simple_move_if_change_rule): Define using move_if_change_rule. * find-defun-files.sh (DEFUN_PATTERN): Update. Don't transform file name extension to ".df". * libinterp/mk-pkg-add, gendoc.pl: Operate directly on source files. * mkbuiltins: New argument, SRCDIR. Operate directly on source files. * mkdefs: Delete. * libinterp/module.mk (BUILT_SOURCES): Update list to contain only files included in other source files. (GENERATED_MAKE_BUILTINS_INCS, DEF_FILES): Delete. (LIBINTERP_BUILT_DISTFILES): Include $(OPT_HANDLERS) here. (LIBINTERP_BUILT_NODISTFILES): Not here. Remove $(ALL_DEF_FILES from the list. (libinterp_EXTRA_DIST): Remove mkdefs from the list. (FOUND_DEFUN_FILES): Rename from SRC_DEF_FILES. (DLDFCN_DEFUN_FILES): Rename from DLDFCN_DEF_FILES. (SRC_DEFUN_FILES): Rename from SRC_DEF_FILES. (ALL_DEFUN_FILES): Rename from ALL_DEF_FILES. (%.df: %.cc): Delete pattern rule. (libinterp/build-env-features.cc, libinterp/builtins.cc, libinterp/dldfcn/PKG_ADD): Use mv instead of move-if-change. (libinterp/builtins.cc, libinterp/builtin-defun-decls.h): Update mkbuiltins command. ($(srcdir)/libinterp/DOCSTRINGS): Update gendoc.pl command. * liboctave/module.mk (BUILT_SOURCES): Don't include liboctave-build-info.cc in the list.
author John W. Eaton <jwe@octave.org>
date Tue, 21 Jun 2016 16:07:51 -0400
parents 1d23b75cbcd1
children d04da18a407a
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
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 18461
diff changeset
3 Copyright (C) 1993-2015 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
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21609
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
24 # include "config.h"
1
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
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
27 #include <csignal>
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
28 #include <cstdlib>
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
29
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3343
diff changeset
30 #include <iostream>
1344
c2ca372d3279 [project @ 1995-09-04 00:50:16 by jwe]
jwe
parents: 1343
diff changeset
31 #include <new>
c2ca372d3279 [project @ 1995-09-04 00:50:16 by jwe]
jwe
parents: 1343
diff changeset
32
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
33 #include "cmd-edit.h"
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5451
diff changeset
34 #include "oct-syscalls.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4092
diff changeset
35 #include "quit.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
36 #include "singleton-cleanup.h"
21938
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents: 21936
diff changeset
37 #include "signal-wrappers.h"
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
38
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
39 #include "debug.h"
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
40 #include "defun.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
41 #include "error.h"
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
42 #include "input.h"
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
43 #include "load-save.h"
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
44 #include "oct-map.h"
2091
60f5e1c20815 [project @ 1996-04-28 08:32:39 by jwe]
jwe
parents: 2016
diff changeset
45 #include "pager.h"
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
46 #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
47 #include "pt-eval.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
48 #include "sighandlers.h"
4787
02c748eb2ddc [project @ 2004-02-18 21:20:26 by jwe]
jwe
parents: 4675
diff changeset
49 #include "sysdep.h"
2091
60f5e1c20815 [project @ 1996-04-28 08:32:39 by jwe]
jwe
parents: 2016
diff changeset
50 #include "toplev.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
51 #include "utils.h"
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
52 #include "variables.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
53
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
54 // 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
55 // SIGPIPES. We assume that the writer will eventually give up.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
56 int pipe_handler_error_count = 0;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
57
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2931
diff changeset
58 // TRUE means we can be interrupted.
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2931
diff changeset
59 bool can_interrupt = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
60
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
61 // 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
62 bool Vdebug_on_interrupt = false;
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
63
14889
577df411e0c7 rename octave-core file to octave-workspace
John W. Eaton <jwe@octave.org>
parents: 14861
diff changeset
64 // 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
65 // 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
66 // 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
67 static bool Vsighup_dumps_octave_core = true;
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
68
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
69 // 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
70 static bool Vsigterm_dumps_octave_core = true;
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
71
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
72 // List of signals we have caught since last call to octave_signal_handler.
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
73 static bool *octave_signals_caught = 0;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
74
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
75 // Forward declaration.
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
76 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
77
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
78 #if defined (__WIN32__) && ! defined (__CYGWIN__)
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 #define WIN32_LEAN_AND_MEAN
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
81 #include <windows.h>
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
82
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
83 class
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
84 w32_interrupt_manager
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
85 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
86 public:
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
87 ~w32_interrupt_manager (void)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
88 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
89 if (thread)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
90 CloseHandle (thread);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
91 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
92
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
93 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
94
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
95 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
96 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
97 if (instance_ok ())
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
98 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
99 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
100
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
101 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
102 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
103 if (instance_ok ())
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
104 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
105 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
106
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
107 static void raise_sigint (void)
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 if (instance_ok ())
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
110 instance->do_raise_sigint ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
111 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
112
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
113 private:
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
114 w32_interrupt_manager (void)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
115 : thread (0), thread_id (0)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
116 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
117 thread_id = GetCurrentThreadId ();
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 DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
120 GetCurrentProcess (), &thread, 0, FALSE,
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
121 DUPLICATE_SAME_ACCESS);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
122 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
123
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
124 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
125 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21609
diff changeset
126 #if defined (_MSC_VER)
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
127 _fpreset ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
128 #endif
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
129 ::octave_jump_to_enclosing_context ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
130 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
131
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
132 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
133 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
134 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
135
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
136 if (is_interrupt_thread)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
137 octave_jump_to_enclosing_context_sync ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
138 else
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
139 {
18461
9cfba3616503 allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents: 17958
diff changeset
140 // 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
141 // 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
142 // 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
143
9cfba3616503 allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents: 17958
diff changeset
144 #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
145
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
146 CONTEXT threadContext;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
147
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
148 SuspendThread (thread);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
149 threadContext.ContextFlags = CONTEXT_CONTROL;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
150 GetThreadContext (thread, &threadContext);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
151 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
152 SetThreadContext (thread, &threadContext);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
153 ResumeThread (thread);
18461
9cfba3616503 allow sighandlers.cc to compile on 64-bit Windows systems
John W. Eaton <jwe@octave.org>
parents: 17958
diff changeset
154 #endif
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
155 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
156 }
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 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
159 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
160 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
161
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
162 if (is_interrupt_thread)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
163 ::user_abort (sig_name, sig_number);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
164 else
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
165 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
166 SuspendThread (thread);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
167 ::user_abort (sig_name, sig_number);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
168 ResumeThread (thread);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
169 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
170 }
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 void do_raise_sigint (void)
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 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
175
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
176 if (is_interrupt_thread)
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
177 octave_raise_wrapper (SIGINT);
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
178 else
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
179 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
180 SuspendThread (thread);
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
181 octave_raise_wrapper (SIGINT);
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
182 ResumeThread (thread);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
183 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
184 }
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 static bool instance_ok (void)
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 bool retval = true;
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 if (! instance)
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 instance = new w32_interrupt_manager ();
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 if (instance)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
195 singleton_cleanup_list::add (cleanup_instance);
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
196 }
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
197
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
198 if (! instance)
20956
850e3d2533d4 maint: Eliminate more useless statements after error().
Rik <rik@octave.org>
parents: 20945
diff changeset
199 error ("unable to create w32_interrupt_manager");
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
200
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
201 return retval;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
202 }
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 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
205
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
206 private:
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
207 // 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
208 HANDLE thread;
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 // 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
211 DWORD thread_id;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
212
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
213 static w32_interrupt_manager* instance;
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
214 };
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 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
217
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
218 void w32_raise_sigint (void)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
219 {
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
220 w32_interrupt_manager::raise_sigint ();
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
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
223 #endif
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
224
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
225 // 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
226 // we have caught.
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
227
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
228 void
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
229 octave_signal_handler (void)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
230 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
231 // 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
232 // linearly through the list.
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
233
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
234 static int sigchld;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
235 static int sigfpe;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
236 static int sigpipe;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
237
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
238 static const bool have_sigchld = octave_get_sig_number ("SIGCHLD", &sigchld);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
239 static const bool have_sigfpe = octave_get_sig_number ("SIGFPE", &sigfpe);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
240 static const bool have_sigpipe = octave_get_sig_number ("SIGPIPE", &sigpipe);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
241
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
242 for (int i = 0; i < octave_num_signals (); i++)
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
243 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
244 if (octave_signals_caught[i])
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
245 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
246 octave_signals_caught[i] = false;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
247
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
248 if (have_sigchld && i == sigchld)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
249 {
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
250 volatile octave_interrupt_handler saved_interrupt_handler
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
251 = octave_ignore_interrupts ();
11555
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
252
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
253 void *context = octave_block_child ();
11555
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
254
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
255 octave_child_list::wait ();
11555
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
256
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
257 octave_set_interrupt_handler (saved_interrupt_handler);
11555
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
258
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
259 octave_unblock_child (context);
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
260
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
261 octave_child_list::reap ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
262 }
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
263 else if (have_sigfpe && i == sigfpe)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
264 std::cerr << "warning: floating point exception" << std::endl;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
265 else if (have_sigpipe && i == sigpipe)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
266 std::cerr << "warning: broken pipe" << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
267 }
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
268 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
269 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
270
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
271 static void
4787
02c748eb2ddc [project @ 2004-02-18 21:20:26 by jwe]
jwe
parents: 4675
diff changeset
272 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
273 bool save_vars = true)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
274 {
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
275 static bool been_there_done_that = false;
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
276
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
277 if (been_there_done_that)
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
278 {
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
279 octave_set_signal_handler ("SIGABRT", SIG_DFL);
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
280
3644
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3566
diff changeset
281 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
282
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
283 MINGW_SIGNAL_CLEANUP ();
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
284
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
285 abort ();
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
286 }
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
287 else
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
288 {
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
289 been_there_done_that = true;
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
290
3644
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3566
diff changeset
291 std::cerr << "panic: " << sig_name << " -- stopping myself...\n";
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
292
4787
02c748eb2ddc [project @ 2004-02-18 21:20:26 by jwe]
jwe
parents: 4675
diff changeset
293 if (save_vars)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
294 dump_octave_core ();
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
295
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3018
diff changeset
296 if (sig_number < 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
297 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
298 MINGW_SIGNAL_CLEANUP ();
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
299
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
300 exit (1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
301 }
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3018
diff changeset
302 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
303 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
304 octave_set_signal_handler (sig_number, SIG_DFL);
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3018
diff changeset
305
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
306 octave_raise_wrapper (sig_number);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
307 }
2536
1d63e820ee13 [project @ 1996-11-19 20:34:29 by jwe]
jwe
parents: 2512
diff changeset
308 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
309 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
310
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
311 octave_sig_handler *
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
312 octave_set_signal_handler (int sig, octave_sig_handler *handler,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
313 bool restart_syscalls)
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
314 {
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
315 return octave_set_signal_handler_internal (sig, handler, restart_syscalls);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
316 }
5144
25b090e1be9f [project @ 2005-02-15 12:06:05 by jwe]
jwe
parents: 5142
diff changeset
317
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
318 octave_sig_handler *
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
319 octave_set_signal_handler (const char *signame, octave_sig_handler *handler,
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
320 bool restart_syscalls)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
321 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
322 return octave_set_signal_handler_by_name (signame, handler,
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
323 restart_syscalls);
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
324 }
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
325
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
326 static void
1446
5135dac66704 [project @ 1995-09-19 22:34:06 by jwe]
jwe
parents: 1395
diff changeset
327 generic_sig_handler (int sig)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
328 {
21938
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents: 21936
diff changeset
329 my_friendly_exit (octave_strsignal_wrapper (sig), sig);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
330 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
331
2091
60f5e1c20815 [project @ 1996-04-28 08:32:39 by jwe]
jwe
parents: 2016
diff changeset
332 // Handle SIGCHLD.
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
333
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
334 static void
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
335 sigchld_handler (int sig)
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
336 {
11555
f359cfc6e24d sighandlers.cc: wait for children in octave_signal_handler, not sigchld_handler
John W. Eaton <jwe@octave.org>
parents: 11525
diff changeset
337 octave_signal_caught = 1;
2626
b35a5cd8107f [project @ 1997-01-27 01:41:30 by jwe]
jwe
parents: 2600
diff changeset
338
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
339 octave_signals_caught[sig] = true;
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
340 }
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
341
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
342 #if defined (__alpha__)
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
343 static void
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
344 sigfpe_handler (int sig)
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
345 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
346 if (can_interrupt && octave_interrupt_state >= 0)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
347 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
348 octave_signal_caught = 1;
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
349
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
350 octave_signals_caught[sig] = true;
4182
4d1d7c51205c [project @ 2002-11-15 20:33:47 by jwe]
jwe
parents: 4181
diff changeset
351
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
352 octave_interrupt_state++;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
353 }
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
354 }
20945
9d9270e2f98f eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents: 20939
diff changeset
355 #endif
1373
cea4101a2f18 [project @ 1995-09-07 07:19:58 by jwe]
jwe
parents: 1358
diff changeset
356
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
357 static void
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
358 sig_hup_handler (int /* sig */)
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
359 {
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
360 if (Vsighup_dumps_octave_core)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
361 dump_octave_core ();
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
362
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
363 clean_up_and_exit (0);
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
364 }
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
365
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
366 static void
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
367 sig_term_handler (int /* sig */)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
368 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
369 if (Vsigterm_dumps_octave_core)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
370 dump_octave_core ();
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
371
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
372 clean_up_and_exit (0);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
373 }
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
374
3343
466d7a1cac01 [project @ 1999-11-05 19:34:29 by jwe]
jwe
parents: 3281
diff changeset
375 #if 0
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
376 static void
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
377 sigwinch_handler (int /* sig */)
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
378 {
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21727
diff changeset
379 octave::command_editor::resize_terminal ();
3281
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
380 }
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
381 #endif
aaaa20d31a5f [project @ 1999-10-13 07:02:46 by jwe]
jwe
parents: 3252
diff changeset
382
635
5338832d2cf6 [project @ 1994-08-23 17:57:20 by jwe]
jwe
parents: 529
diff changeset
383 // 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
384 //
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
385 // 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
386 // 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
387 // for SIGINT only.
635
5338832d2cf6 [project @ 1994-08-23 17:57:20 by jwe]
jwe
parents: 529
diff changeset
388
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
389 static void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
390 user_abort (const char *sig_name, int sig_number)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
391 {
4172
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4153
diff changeset
392 if (! octave_initialized)
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4153
diff changeset
393 exit (1);
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 4153
diff changeset
394
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
395 if (can_interrupt)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
396 {
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
397 if (Vdebug_on_interrupt)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
398 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
399 if (! octave_debug_on_interrupt_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
400 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
401 tree_evaluator::debug_mode = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
402 octave_debug_on_interrupt_state = true;
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
403
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
404 return;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
405 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
406 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
407 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
408 // 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
409
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
410 tree_evaluator::debug_mode
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
411 = bp_table::have_breakpoints () || Vdebugging;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
412 octave_debug_on_interrupt_state = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
413 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
414 }
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
415
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4092
diff changeset
416 if (octave_interrupt_immediately)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
417 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
418 if (octave_interrupt_state == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
419 octave_interrupt_state = 1;
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
420
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
421 #if defined (__WIN32__) && ! defined (__CYGWIN__)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
422 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
423 #else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
424 octave_jump_to_enclosing_context ();
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
425 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
426 }
4429
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4294
diff changeset
427 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
428 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
429 // 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
430 // 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
431 // arrived.
4793
a62215ab8a03 [project @ 2004-02-20 20:59:34 by jwe]
jwe
parents: 4791
diff changeset
432
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
433 if (octave_interrupt_state < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
434 octave_interrupt_state = 0;
4793
a62215ab8a03 [project @ 2004-02-20 20:59:34 by jwe]
jwe
parents: 4791
diff changeset
435
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
436 octave_signal_caught = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
437 octave_interrupt_state++;
4787
02c748eb2ddc [project @ 2004-02-18 21:20:26 by jwe]
jwe
parents: 4675
diff changeset
438
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
439 if (interactive && ! forced_interactive
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
440 && octave_interrupt_state == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
441 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
442
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
443 if (octave_interrupt_state >= 3)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
444 my_friendly_exit (sig_name, sig_number, true);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
445 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
446 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
447
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
448 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
449
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
450 static void
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
451 sigint_handler (int sig)
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5333
diff changeset
452 {
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
453 #if defined (__WIN32__) && ! defined (__CYGWIN__)
21938
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents: 21936
diff changeset
454 w32_interrupt_manager::user_abort (octave_strsignal_wrapper (sig), sig);
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
455 #else
21938
da9b960b1b2d use gnulib strsignal module
John W. Eaton <jwe@octave.org>
parents: 21936
diff changeset
456 user_abort (octave_strsignal_wrapper (sig), sig);
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
457 #endif
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
458 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
459
10246
f751dae7aab8 use gnulib signal modules
John W. Eaton <jwe@octave.org>
parents: 10194
diff changeset
460 static void
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
461 sigpipe_handler (int sig)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
462 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
463 octave_signal_caught = 1;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
464
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
465 octave_signals_caught[sig] = true;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
466
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
467 // Don't loop forever on account of this.
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1352
diff changeset
468
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
469 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
470 octave_interrupt_state++;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
471 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
472
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
473 octave_interrupt_handler
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
474 octave_catch_interrupts (void)
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
475 {
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
476 octave_interrupt_handler retval;
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
477
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
478 #if defined (__WIN32__) && ! defined (__CYGWIN__)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
479 w32_interrupt_manager::init ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
480 #endif
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
481
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
482 retval.int_handler = octave_set_signal_handler ("SIGINT", sigint_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
483 retval.brk_handler = octave_set_signal_handler ("SIGBREAK", sigint_handler);
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
484
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
485 return retval;
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
486 }
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
487
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
488 octave_interrupt_handler
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
489 octave_ignore_interrupts (void)
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
490 {
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
491 octave_interrupt_handler retval;
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
492
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
493 #if defined (__WIN32__) && ! defined (__CYGWIN__)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
494 w32_interrupt_manager::init ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
495 #endif
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
496
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
497 retval.int_handler = octave_set_signal_handler ("SIGINT", SIG_IGN);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
498 retval.brk_handler = octave_set_signal_handler ("SIGBREAK", SIG_IGN);
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
499
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
500 return retval;
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
501 }
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
502
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
503 octave_interrupt_handler
5770
6a9244f89a2a [project @ 2006-04-18 17:44:33 by jwe]
jwe
parents: 5453
diff changeset
504 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
505 bool restart_syscalls)
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
506 {
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
507 octave_interrupt_handler retval;
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
508
17958
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
509 #if defined (__WIN32__) && ! defined (__CYGWIN__)
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
510 w32_interrupt_manager::init ();
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
511 #endif
1adf3710bb68 Working CTRL-C handling implementation for Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17861
diff changeset
512
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
513 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
514 restart_syscalls);
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
515
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
516 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
517 restart_syscalls);
2705
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
518
18395aaeafb7 [project @ 1997-02-20 04:56:43 by jwe]
jwe
parents: 2693
diff changeset
519 return retval;
1651
e846e361a265 [project @ 1995-12-20 06:59:12 by jwe]
jwe
parents: 1618
diff changeset
520 }
e846e361a265 [project @ 1995-12-20 06:59:12 by jwe]
jwe
parents: 1618
diff changeset
521
635
5338832d2cf6 [project @ 1994-08-23 17:57:20 by jwe]
jwe
parents: 529
diff changeset
522 // 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
523
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
524 void
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
525 install_signal_handlers (void)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
526 {
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
527 if (! octave_signals_caught)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
528 octave_signals_caught = new bool [octave_num_signals ()];
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
529
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
530 for (int i = 0; i < octave_num_signals (); i++)
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
531 octave_signals_caught[i] = false;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
532
2554
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
533 octave_catch_interrupts ();
f7e3d23f0a8f [project @ 1996-11-21 01:41:57 by jwe]
jwe
parents: 2536
diff changeset
534
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
535 octave_set_signal_handler ("SIGABRT", generic_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
536 octave_set_signal_handler ("SIGALRM", generic_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
537 octave_set_signal_handler ("SIGBUS", generic_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
538 octave_set_signal_handler ("SIGCHLD", sigchld_handler);
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1009
diff changeset
539
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
540 // SIGCLD
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
541 // SIGCONT
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
542
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
543 octave_set_signal_handler ("SIGEMT", generic_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
544
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
545 #if defined (__alpha__)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
546 octave_set_signal_handler ("SIGFPE", sigfpe_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
547 #else
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
548 octave_set_signal_handler ("SIGFPE", generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
549 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
550
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
551 octave_set_signal_handler ("SIGHUP", sig_hup_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
552 octave_set_signal_handler ("SIGILL", generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
553
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
554 // SIGINFO
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
555 // SIGINT
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
556
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
557 octave_set_signal_handler ("SIGIOT", generic_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
558 octave_set_signal_handler ("SIGLOST", generic_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
559 octave_set_signal_handler ("SIGPIPE", sigpipe_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
560 octave_set_signal_handler ("SIGPOLL", SIG_IGN);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
561
5866
f9ac7ebf0e19 [project @ 2006-06-28 16:05:22 by jwe]
jwe
parents: 5844
diff changeset
562 // SIGPROF
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
563 // SIGPWR
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
564
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
565 octave_set_signal_handler ("SIGQUIT", generic_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
566 octave_set_signal_handler ("SIGSEGV", generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
567
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
568 // SIGSTOP
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
569
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
570 octave_set_signal_handler ("SIGSYS", generic_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
571 octave_set_signal_handler ("SIGTERM", sig_term_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
572 octave_set_signal_handler ("SIGTRAP", generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
573
3174
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
574 // SIGTSTP
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
575 // SIGTTIN
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
576 // SIGTTOU
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
577 // SIGURG
390d5e396682 [project @ 1998-05-04 16:36:17 by jwe]
jwe
parents: 3162
diff changeset
578
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
579 octave_set_signal_handler ("SIGUSR1", generic_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
580 octave_set_signal_handler ("SIGUSR2", generic_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
581 octave_set_signal_handler ("SIGVTALRM", generic_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
582 octave_set_signal_handler ("SIGIO", SIG_IGN);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
583
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
584 #if 0
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
585 octave_set_signal_handler ("SIGWINCH", sigwinch_handler);
895
05654cdcfc95 [project @ 1994-11-09 15:30:06 by jwe]
jwe
parents: 886
diff changeset
586 #endif
05654cdcfc95 [project @ 1994-11-09 15:30:06 by jwe]
jwe
parents: 886
diff changeset
587
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
588 octave_set_signal_handler ("SIGXCPU", generic_sig_handler);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
589 octave_set_signal_handler ("SIGXFSZ", generic_sig_handler);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
590 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
591
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
592 static void
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
593 set_sig_struct_field (octave_scalar_map& m, const char *signame)
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
594 {
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
595 int signum;
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
596
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
597 // The names in the struct do not include the leading "SIG" prefix.
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
598
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
599 if (octave_get_sig_number (signame, &signum))
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
600 m.assign (&signame[3], signum);
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
601 }
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
602
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
603 static octave_scalar_map
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
604 make_sig_struct (void)
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
605 {
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
606 octave_scalar_map m;
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
607
21941
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
608 set_sig_struct_field (m, "SIGABRT");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
609 set_sig_struct_field (m, "SIGALRM");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
610 set_sig_struct_field (m, "SIGBUS");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
611 set_sig_struct_field (m, "SIGCHLD");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
612 set_sig_struct_field (m, "SIGCLD");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
613 set_sig_struct_field (m, "SIGCONT");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
614 set_sig_struct_field (m, "SIGEMT");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
615 set_sig_struct_field (m, "SIGFPE");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
616 set_sig_struct_field (m, "SIGHUP");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
617 set_sig_struct_field (m, "SIGILL");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
618 set_sig_struct_field (m, "SIGINFO");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
619 set_sig_struct_field (m, "SIGINT");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
620 set_sig_struct_field (m, "SIGIO");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
621 set_sig_struct_field (m, "SIGIOT");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
622 set_sig_struct_field (m, "SIGKILL");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
623 set_sig_struct_field (m, "SIGLOST");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
624 set_sig_struct_field (m, "SIGPIPE");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
625 set_sig_struct_field (m, "SIGPOLL");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
626 set_sig_struct_field (m, "SIGPROF");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
627 set_sig_struct_field (m, "SIGPWR");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
628 set_sig_struct_field (m, "SIGQUIT");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
629 set_sig_struct_field (m, "SIGSEGV");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
630 set_sig_struct_field (m, "SIGSTKFLT");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
631 set_sig_struct_field (m, "SIGSTOP");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
632 set_sig_struct_field (m, "SIGSYS");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
633 set_sig_struct_field (m, "SIGTERM");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
634 set_sig_struct_field (m, "SIGTRAP");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
635 set_sig_struct_field (m, "SIGTSTP");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
636 set_sig_struct_field (m, "SIGTTIN");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
637 set_sig_struct_field (m, "SIGTTOU");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
638 set_sig_struct_field (m, "SIGUNUSED");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
639 set_sig_struct_field (m, "SIGURG");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
640 set_sig_struct_field (m, "SIGUSR1");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
641 set_sig_struct_field (m, "SIGUSR2");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
642 set_sig_struct_field (m, "SIGVTALRM");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
643 set_sig_struct_field (m, "SIGWINCH");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
644 set_sig_struct_field (m, "SIGXCPU");
1d23b75cbcd1 hide signal.h from C++ sources
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
645 set_sig_struct_field (m, "SIGXFSZ");
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
646
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
647 return m;
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
648 }
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
649
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
650 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
651
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
652 bool
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
653 octave_child_list::instance_ok (void)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
654 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
655 bool retval = true;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
656
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
657 if (! instance)
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
658 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
659 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
660
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
661 if (instance)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
662 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
663 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
664
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
665 if (! instance)
20956
850e3d2533d4 maint: Eliminate more useless statements after error().
Rik <rik@octave.org>
parents: 20945
diff changeset
666 error ("unable to create child list object!");
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
667
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
668 return retval;
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
669 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
670
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
671 void
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
672 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
673 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
674 if (instance_ok ())
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
675 instance->insert (pid, f);
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
676 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
677
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
678 void
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
679 octave_child_list::reap (void)
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
680 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
681 if (instance_ok ())
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
682 instance->reap ();
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
683 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
684
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
685 bool
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
686 octave_child_list::wait (void)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
687 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
688 return (instance_ok ()) ? instance->wait () : false;
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
689 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
690
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
691 class pid_equal
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
692 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
693 public:
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
694
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
695 pid_equal (pid_t v) : val (v) { }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
696
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
697 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
698
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
699 private:
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
700
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
701 pid_t val;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
702 };
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
703
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
704 void
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
705 octave_child_list::remove (pid_t pid)
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
706 {
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
707 if (instance_ok ())
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
708 instance->remove_if (pid_equal (pid));
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
709 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
710
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
711 #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
712
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
713 void
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
714 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
715 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
716 append (octave_child (pid, f));
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
717 }
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
718
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
719 void
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
720 OCL_REP::reap (void)
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
721 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
722 // Mark the record for PID invalid.
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
723
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
724 for (iterator p = begin (); p != end (); p++)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
725 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
726 // 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
727 // invalidate the iterator (for example, by calling
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
728 // octave_child_list::remove), so we increment the iterator
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
729 // here.
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
730
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
731 octave_child& oc = *p;
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
732
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
733 if (oc.have_status)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
734 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
735 oc.have_status = 0;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
736
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
737 octave_child::child_event_handler f = oc.handler;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
738
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
739 if (f && f (oc.pid, oc.status))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
740 oc.pid = -1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
741 }
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
742 }
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
743
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
744 remove_if (pid_equal (-1));
2209
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
745 }
859030f15706 [project @ 1996-05-15 11:46:43 by jwe]
jwe
parents: 2206
diff changeset
746
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
747 // 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
748
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
749 bool
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
750 OCL_REP::wait (void)
2210
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
751 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
752 bool retval = false;
2210
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
753
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
754 for (iterator p = begin (); p != end (); p++)
2210
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
755 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
756 octave_child& oc = *p;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
757
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
758 pid_t pid = oc.pid;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
759
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
760 if (pid > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
761 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
762 int status;
2210
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
763
21936
45c5f4426289 Use library wrapper for one more instance of WNOHANG (bug #48253)
Mike Miller <mtmiller@octave.org>
parents: 21921
diff changeset
764 if (octave::sys::waitpid (pid, &status, octave::sys::wnohang ()) > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
765 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
766 oc.have_status = 1;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
767
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
768 oc.status = status;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
769
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
770 retval = true;
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
771
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
772 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
773 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10246
diff changeset
774 }
2210
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
775 }
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
776
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5128
diff changeset
777 return retval;
2210
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
778 }
a3e39f8efed2 [project @ 1996-05-15 12:55:55 by jwe]
jwe
parents: 2209
diff changeset
779
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
780 DEFUN (SIG, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
781 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
782 @deftypefn {} {} SIG ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
783 Return a structure containing Unix signal names and their defined values.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
784 @end deftypefn */)
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
785 {
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
786 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
787 print_usage ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
788
20801
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
789 static octave_scalar_map m = make_sig_struct ();
a542a9bf177e eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
790
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
791 return ovl (m);
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
792 }
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
793
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
794 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
795 %!assert (isstruct (SIG ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
796 %!assert (! isempty (SIG ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
797
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
798 %!error SIG (1)
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
799 */
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
800
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
801 DEFUN (debug_on_interrupt, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
802 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
803 @deftypefn {} {@var{val} =} debug_on_interrupt ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
804 @deftypefnx {} {@var{old_val} =} debug_on_interrupt (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
805 @deftypefnx {} {} debug_on_interrupt (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
806 Query or set the internal variable that controls whether Octave will try
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
807 to enter debugging mode when it receives an interrupt signal (typically
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
808 generated with @kbd{C-c}).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
809
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
810 If a second interrupt signal is received before reaching the debugging mode,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
811 a normal interrupt will occur.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
812
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
813 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
814 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
815 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
816 @seealso{debug_on_error, debug_on_warning}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
817 @end deftypefn */)
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
818 {
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
819 return SET_INTERNAL_VARIABLE (debug_on_interrupt);
4449
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
820 }
e2c91da0aa16 [project @ 2003-07-09 02:21:11 by jwe]
jwe
parents: 4429
diff changeset
821
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
822 /*
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
823 %!test
12832
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
824 %! orig_val = debug_on_interrupt ();
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
825 %! old_val = debug_on_interrupt (! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
826 %! assert (orig_val, old_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
827 %! assert (debug_on_interrupt (), ! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
828 %! debug_on_interrupt (orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
829 %! 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
830
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
831 %!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
832 */
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
833
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
834 DEFUN (sighup_dumps_octave_core, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
835 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
836 @deftypefn {} {@var{val} =} sighup_dumps_octave_core ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
837 @deftypefnx {} {@var{old_val} =} sighup_dumps_octave_core (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
838 @deftypefnx {} {} sighup_dumps_octave_core (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
839 Query or set the internal variable that controls whether Octave tries
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
840 to save all current variables to the file @file{octave-workspace} if it
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
841 receives a hangup signal.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
842
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
843 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
844 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
845 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
846 @end deftypefn */)
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
847 {
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
848 return SET_INTERNAL_VARIABLE (sighup_dumps_octave_core);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
849 }
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4233
diff changeset
850
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
851 /*
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
852 %!test
12832
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
853 %! orig_val = sighup_dumps_octave_core ();
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
854 %! old_val = sighup_dumps_octave_core (! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
855 %! assert (orig_val, old_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
856 %! assert (sighup_dumps_octave_core (), ! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
857 %! sighup_dumps_octave_core (orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
858 %! 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
859
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
860 %!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
861 */
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
862
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
863 DEFUN (sigterm_dumps_octave_core, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
864 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
865 @deftypefn {} {@var{val} =} sigterm_dumps_octave_core ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
866 @deftypefnx {} {@var{old_val} =} sigterm_dumps_octave_core (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
867 @deftypefnx {} {} sigterm_dumps_octave_core (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
868 Query or set the internal variable that controls whether Octave tries
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
869 to save all current variables to the file @file{octave-workspace} if it
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
870 receives a terminate signal.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
871
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
872 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
873 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
874 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21941
diff changeset
875 @end deftypefn */)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
876 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
877 return SET_INTERNAL_VARIABLE (sigterm_dumps_octave_core);
4185
8f6d418d31c3 [project @ 2002-11-15 23:22:03 by jwe]
jwe
parents: 4182
diff changeset
878 }
12827
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
879
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
880 /*
8c6d71520920 codesprint: new tests for sysdep.cc functions
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
881 %!test
12832
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
882 %! orig_val = sigterm_dumps_octave_core ();
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
883 %! old_val = sigterm_dumps_octave_core (! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
884 %! assert (orig_val, old_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
885 %! assert (sigterm_dumps_octave_core (), ! orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
886 %! sigterm_dumps_octave_core (orig_val);
03f125c0fb7b codesprint: improve tests
John W. Eaton <jwe@octave.org>
parents: 12827
diff changeset
887 %! 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
888
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14338
diff changeset
889 %!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
890 */