1 | '\" |
---|
2 | '\" See the file "license.terms" for information on usage and redistribution |
---|
3 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
4 | '\" |
---|
5 | '\" RCS: @(#) $Id: Panic.3,v 1.8 2005/09/13 21:23:51 dgp Exp $ |
---|
6 | '\" |
---|
7 | .so man.macros |
---|
8 | .TH Tcl_Panic 3 8.4 Tcl "Tcl Library Procedures" |
---|
9 | .BS |
---|
10 | '\" Note: do not modify the .SH NAME line immediately below! |
---|
11 | .SH NAME |
---|
12 | Tcl_Panic, Tcl_PanicVA, Tcl_SetPanicProc \- report fatal error and abort |
---|
13 | .SH SYNOPSIS |
---|
14 | .nf |
---|
15 | \fB#include <tcl.h>\fR |
---|
16 | .sp |
---|
17 | void |
---|
18 | \fBTcl_Panic\fR(\fIformat\fR, \fIarg\fR, \fIarg\fR, \fI...\fR) |
---|
19 | .sp |
---|
20 | void |
---|
21 | \fBTcl_PanicVA\fR(\fIformat\fR, \fIargList\fR) |
---|
22 | .sp |
---|
23 | void |
---|
24 | \fBTcl_SetPanicProc\fR(\fIpanicProc\fR) |
---|
25 | .sp |
---|
26 | .SH ARGUMENTS |
---|
27 | .AS Tcl_PanicProc *panicProc |
---|
28 | .AP "const char*" format in |
---|
29 | A printf-style format string. |
---|
30 | .AP "" arg in |
---|
31 | Arguments matching the format string. |
---|
32 | .AP va_list argList in |
---|
33 | An argument list of arguments matching the format string. |
---|
34 | Must have been initialized using \fBva_start\fR, |
---|
35 | and cleared using \fBva_end\fR. |
---|
36 | .AP Tcl_PanicProc *panicProc in |
---|
37 | Procedure to report fatal error message and abort. |
---|
38 | |
---|
39 | .BE |
---|
40 | |
---|
41 | .SH DESCRIPTION |
---|
42 | .PP |
---|
43 | When the Tcl library detects that its internal data structures are in an |
---|
44 | inconsistent state, or that its C procedures have been called in a |
---|
45 | manner inconsistent with their documentation, it calls \fBTcl_Panic\fR |
---|
46 | to display a message describing the error and abort the process. The |
---|
47 | \fIformat\fR argument is a format string describing how to format the |
---|
48 | remaining arguments \fIarg\fR into an error message, according to the |
---|
49 | same formatting rules used by the \fBprintf\fR family of functions. The |
---|
50 | same formatting rules are also used by the built-in Tcl command |
---|
51 | \fBformat\fR. |
---|
52 | .PP |
---|
53 | In a freshly loaded Tcl library, \fBTcl_Panic\fR prints the formatted |
---|
54 | error message to the standard error file of the process, and then |
---|
55 | calls \fBabort\fR to terminate the process. \fBTcl_Panic\fR does not |
---|
56 | return. |
---|
57 | .PP |
---|
58 | \fBTcl_SetPanicProc\fR may be used to modify the behavior of |
---|
59 | \fBTcl_Panic\fR. The \fIpanicProc\fR argument should match the |
---|
60 | type \fBTcl_PanicProc\fR: |
---|
61 | .PP |
---|
62 | .CS |
---|
63 | typedef void Tcl_PanicProc( |
---|
64 | const char *\fBformat\fR, |
---|
65 | \fBarg\fR, \fBarg\fR,...); |
---|
66 | .CE |
---|
67 | .PP |
---|
68 | After \fBTcl_SetPanicProc\fR returns, any future calls to |
---|
69 | \fBTcl_Panic\fR will call \fIpanicProc\fR, passing along the |
---|
70 | \fIformat\fR and \fIarg\fR arguments. To maintain consistency with the |
---|
71 | callers of \fBTcl_Panic\fR, \fIpanicProc\fR must not return; it must |
---|
72 | call \fBabort\fR. \fIpanicProc\fR should avoid making calls into the |
---|
73 | Tcl library, or into other libraries that may call the Tcl library, |
---|
74 | since the original call to \fBTcl_Panic\fR indicates the Tcl library is |
---|
75 | not in a state of reliable operation. |
---|
76 | .PP |
---|
77 | The typical use of \fBTcl_SetPanicProc\fR arranges for the error message |
---|
78 | to be displayed or reported in a manner more suitable for the |
---|
79 | application or the platform. As an example, the Windows implementation |
---|
80 | of \fBwish\fR calls \fBTcl_SetPanicProc\fR to force all panic messages |
---|
81 | to be displayed in a system dialog box, rather than to be printed to the |
---|
82 | standard error file (usually not visible under Windows). |
---|
83 | .PP |
---|
84 | Although the primary callers of \fBTcl_Panic\fR are the procedures of |
---|
85 | the Tcl library, \fBTcl_Panic\fR is a public function and may be called |
---|
86 | by any extension or application that wishes to abort the process and |
---|
87 | have a panic message displayed the same way that panic messages from Tcl |
---|
88 | will be displayed. |
---|
89 | .PP |
---|
90 | \fBTcl_PanicVA\fR is the same as \fBTcl_Panic\fR except that instead of |
---|
91 | taking a variable number of arguments it takes an argument list. |
---|
92 | |
---|
93 | .SH "SEE ALSO" |
---|
94 | abort(3), printf(3), exec(n), format(n) |
---|
95 | |
---|
96 | .SH KEYWORDS |
---|
97 | abort, fatal, error |
---|
98 | |
---|