Tcl_Exit (3)
end the application (and invoke exit handlers)
SYNOPSIS
#include <tcl.h>
Tcl_Exit(status)
Tcl_Finalize()
Tcl_CreateExitHandler(proc, clientData)
Tcl_DeleteExitHandler(proc, clientData)
ARGUMENTS
Tcl_ExitProc clientData
int status in
Provides information about why application exited. Exact meaning may
be platform-specific. 0 usually means a normal exit, any nonzero value
usually means that an error occurred.
Tcl_ExitProc *proc in
Procedure to invoke before exiting application.
ClientData clientData in
Arbitrary one-word value to pass to proc.
DESCRIPTION
The procedures described here provide a graceful mechanism to end the
execution of a Tcl application. Exit handlers are invoked to cleanup the
application's state before ending the execution of Tcl code.
Invoke Tcl_Exit to end a Tcl application and to exit from this
process. This procedure is invoked by the exit command, and can be
invoked anyplace else to terminate the application.
No-one should ever invoke the exit system procedure directly; always
invoke Tcl_Exit instead, so that it can invoke exit handlers.
Note that if other code invokes exit system procedure directly, or
otherwise causes the application to terminate without calling
Tcl_Exit, the exit handlers will not be run.
Tcl_Exit internally invokes the exit system call, thus it never
returns control to its caller.
Tcl_Finalize is similar to Tcl_Exit except that it does not
exit from the current process.
It is useful for cleaning up when a process is finished using Tcl but
wishes to continue executing, and when Tcl is used in a dynamically
loaded extension that is about to be unloaded.
On some systems Tcl is automatically notified when it is being
unloaded, and it calls Tcl_Finalize internally; on these systems it
not necessary for the caller to explicitly call Tcl_Finalize.
However, to ensure portability, your code should always invoke
Tcl_Finalize when Tcl is being unloaded, to ensure that the
code will work on all platforms. Tcl_Finalize can be safely called
more than once.
Tcl_CreateExitHandler arranges for proc to be invoked
by Tcl_Finalize and Tcl_Exit.
This provides a hook for cleanup operations such as flushing buffers
and freeing global memory.
Proc should match the type Tcl_ExitProc:
typedef void Tcl_ExitProc(ClientData clientData);
The clientData parameter to proc is a
copy of the clientData argument given to
Tcl_CreateExitHandler when the callback
was created. Typically, clientData points to a data
structure containing application-specific information about
what to do in proc.
Tcl_DeleteExitHandler may be called to delete a
previously-created exit handler. It removes the handler
indicated by proc and clientData so that no call
to proc will be made. If no such handler exists then
Tcl_DeleteExitHandler does nothing.
Tcl_Finalize and Tcl_Exit execute all registered exit handlers,
in reverse order from the order in which they were registered.
This matches the natural order in which extensions are loaded and unloaded;
if extension A loads extension B, it usually
unloads B before it itself is unloaded.
If extension A registers its exit handlers before loading extension
B, this ensures that any exit handlers for B will be executed
before the exit handlers for A.
KEYWORDS
callback, cleanup, dynamic loading, end application, exit, unloading
'\"
'\" Copyright (c) 1995-1996 Sun Microsystems, Inc.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
'\" RCS: @(#) $Id: FindExec.3,v 1.3 1998/09/14 18:39:48 stanton Exp $
'\"
'\" The definitions below are for supplemental macros used in Tcl/Tk
'\" manual entries.
'\"
'\" .AP type name in/out ?indent?
'\" Start paragraph describing an argument to a library procedure.
'\" type is type of argument (int, etc.), in/out is either "in", "out",
'\" or "in/out" to describe whether procedure reads or modifies arg,
'\" and indent is equivalent to second arg of .IP (shouldn't ever be
'\" needed; use .AS below instead)
'\"
'\" .AS ?type? ?name?
'\" Give maximum sizes of arguments for setting tab stops. Type and
'\" name are examples of largest possible arguments that will be passed
'\" to .AP later. If args are omitted, default tab stops are used.
'\"
'\" .BS
'\" Start box enclosure. From here until next .BE, everything will be
'\" enclosed in one large box.
'\"
'\" .BE
'\" End of box enclosure.
'\"
'\" .CS
'\" Begin code excerpt.
'\"
'\" .CE
'\" End code excerpt.
'\"
'\" .VS ?version? ?br?
'\" Begin vertical sidebar, for use in marking newly-changed parts
'\" of man pages. The first argument is ignored and used for recording
'\" the version when the .VS was added, so that the sidebars can be
'\" found and removed when they reach a certain age. If another argument
'\" is present, then a line break is forced before starting the sidebar.
'\"
'\" .VE
'\" End of vertical sidebar.
'\"
'\" .DS
'\" Begin an indented unfilled display.
'\"
'\" .DE
'\" End of indented unfilled display.
'\"
'\" .SO
'\" Start of list of standard options for a Tk widget. The
'\" options follow on successive lines, in four columns separated
'\" by tabs.
'\"
'\" .SE
'\" End of list of standard options for a Tk widget.
'\"
'\" .OP cmdName dbName dbClass
'\" Start of description of a specific option. cmdName gives the
'\" option's name as specified in the class command, dbName gives
'\" the option's name in the option database, and dbClass gives
'\" the option's class in the option database.
'\"
'\" .UL arg1 arg2
'\" Print arg1 underlined, then print arg2 normally.
'\"
'\" RCS: @(#) $Id: man.macros,v 1.2 1998/09/14 18:39:54 stanton Exp $
'\"
'\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
t .wh -1.3i ^B
^l \n(.l
b
'\" # Start an argument description
AP
!"\\$4"" .TP \\$4
\{\
!"\\$2"" .TP \\n()Cu
.TP 15
|