3 While a calculation is in progress, you can generate the SIGINT
4 signal, and the calculator will catch it. At appropriate points
5 within a calculation, the calculator will check that the signal
6 has been given, and will abort the calculation cleanly. If the
7 calculator is in the middle of a large calculation, it might be
8 a while before the interrupt has an effect.
10 You can generate the SIGINT signal multiple times if necessary,
11 and each time the calculator will abort the calculation at a more
12 risky place within the calculation. Each new interrupt prints a
17 where n ranges from 1 to 3. For n equal to 1, the calculator will
18 abort calculations at the next statement boundary specified by an
19 ABORT opcode as described below. For n equal to 2, the calculator
20 will abort calculations at the next opcode boundary. For n equal to 3,
21 the calculator will abort calculations at the next attempt to allocate
22 memory for the result of an integer arithmetic operation; this
23 level may be appropriate for stopping a builtin operation like
24 inversion of a large matrix.
26 If a final interrupt is given when n is 3, the calculator will
27 immediately abort the current calculation and longjmp back to the
28 top level command level. Doing this may result in corrupted data
29 structures and unpredictable future behavior, and so should only
30 be done as a last resort. You are advised to quit the calculator
31 after this has been done.
35 If config("trace") & 2 is zero, ABORT opcodes are introduced at
36 various places in the opcodes for evaluation of command lines
37 and functions defined by "define ... { ... }" commands. In the
38 following, config("trace") has been set equal to 8 so that opcodes
39 are displayed when a function is defined. The function f(x)
40 evaluates x + (x - 1) + (x - 2) + ... until a zero term is
41 encountered. If f() is called with a negative or fractional x,
42 the calculation is never completed and to stop it, an interruption
43 (on many systems, by ctrl-C) will be necessary.
46 ; define f(x) {local s; while (x) {s += x--} return s}
64 (The line number following DEBUG refers to the line in the file
65 from which the definition is read.) If an attempt is made to
66 evaluate f(-1), the effect of the DEBUG at opcode 6 ensures that
67 a single SIGINT will stop the calculation at a start of
68 {s += x--} loop. In interactive mode, with ^C indicating
69 input of ctrl-C, the displayed output is as in:
74 "f": line 2: Calculation aborted at statement boundary
76 The DEBUG opcodes are disabled by nonzero config("trace") & 2.
77 Changing config("trace") to achieve this, and defining g(x) with
78 the same definition as for f(x) gives:
80 ; define g(x) {local s; while (x) {s += x--} return s}
95 If g(-1) is called, two interrupts are necessary, as in:
102 "g": Calculation aborted in opcode
104 ## Copyright (C) 1999-2006 David I. Bell, Landon Curt Noll and Ernest Bowen
106 ## Calc is open software; you can redistribute it and/or modify it under
107 ## the terms of the version 2.1 of the GNU Lesser General Public License
108 ## as published by the Free Software Foundation.
110 ## Calc is distributed in the hope that it will be useful, but WITHOUT
111 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
112 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
113 ## Public License for more details.
115 ## A copy of version 2.1 of the GNU Lesser General Public License is
116 ## distributed with calc under the filename COPYING-LGPL. You should have
117 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
118 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
120 ## @(#) $Revision: 30.1 $
121 ## @(#) $Id: interrupt,v 30.1 2007/03/16 11:10:42 chongo Exp $
122 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/interrupt,v $
124 ## Under source code control: 1991/07/21 04:37:21
125 ## File existed as early as: 1991
127 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
128 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/