Exit.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:5k
- '"
- '" 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: Exit.3,v 1.4 2000/07/24 00:03:02 jenglish Exp $
- '"
- .so man.macros
- .TH Tcl_Exit 3 8.1 Tcl "Tcl Library Procedures"
- .BS
- .SH NAME
- Tcl_Exit, Tcl_Finalize, Tcl_CreateExitHandler, Tcl_DeleteExitHandler, Tcl_ExitThread, Tcl_FinalizeThread, Tcl_CreateThreadExitHandler, Tcl_DeleteThreadExitHandler - end the application or thread (and invoke exit handlers)
- .SH SYNOPSIS
- .nf
- fB#include <tcl.h>fR
- .sp
- fBTcl_ExitfR(fIstatusfR)
- .sp
- fBTcl_FinalizefR()
- .sp
- fBTcl_CreateExitHandlerfR(fIproc, clientDatafR)
- .sp
- fBTcl_DeleteExitHandlerfR(fIproc, clientDatafR)
- .sp
- fBTcl_ExitThreadfR(fIstatusfR)
- .sp
- fBTcl_FinalizeThreadfR()
- .sp
- fBTcl_CreateThreadExitHandlerfR(fIproc, clientDatafR)
- .sp
- fBTcl_DeleteThreadExitHandlerfR(fIproc, clientDatafR)
- .SH ARGUMENTS
- .AS Tcl_ExitProc clientData
- .AP int status in
- Provides information about why the application or thread exited.
- Exact meaning may
- be platform-specific. 0 usually means a normal exit, any nonzero value
- usually means that an error occurred.
- .AP Tcl_ExitProc *proc in
- Procedure to invoke before exiting application.
- .AP ClientData clientData in
- Arbitrary one-word value to pass to fIprocfR.
- .BE
- .SH DESCRIPTION
- .PP
- The procedures described here provide a graceful mechanism to end the
- execution of a fBTclfR application. Exit handlers are invoked to cleanup the
- application's state before ending the execution of fBTclfR code.
- .PP
- Invoke fBTcl_ExitfR to end a fBTclfR application and to exit from this
- process. This procedure is invoked by the fBexitfR command, and can be
- invoked anyplace else to terminate the application.
- No-one should ever invoke the fBexitfR system procedure directly; always
- invoke fBTcl_ExitfR instead, so that it can invoke exit handlers.
- Note that if other code invokes fBexitfR system procedure directly, or
- otherwise causes the application to terminate without calling
- fBTcl_ExitfR, the exit handlers will not be run.
- fBTcl_ExitfR internally invokes the fBexitfR system call, thus it never
- returns control to its caller.
- .PP
- fBTcl_FinalizefR is similar to fBTcl_ExitfR except that it does not
- exit from the current process.
- It is useful for cleaning up when a process is finished using fBTclfR but
- wishes to continue executing, and when fBTclfR is used in a dynamically
- loaded extension that is about to be unloaded.
- On some systems fBTclfR is automatically notified when it is being
- unloaded, and it calls fBTcl_FinalizefR internally; on these systems it
- not necessary for the caller to explicitly call fBTcl_FinalizefR.
- However, to ensure portability, your code should always invoke
- fBTcl_FinalizefR when fBTclfR is being unloaded, to ensure that the
- code will work on all platforms. fBTcl_FinalizefR can be safely called
- more than once.
- .PP
- .VS
- fBTcl_ExitThreadfR is used to terminate the current thread and invoke
- per-thread exit handlers. This finalization is done by
- fBTcl_FinalizeThreadfR, which you can call if you just want to clean
- up per-thread state and invoke the thread exit handlers.
- fBTcl_FinalizefR calls fBTcl_FinalizeThreadfR for the current
- thread automatically.
- .VE
- .PP
- fBTcl_CreateExitHandlerfR arranges for fIprocfR to be invoked
- by fBTcl_FinalizefR and fBTcl_ExitfR.
- fBTcl_CreateThreadExitHandlerfR arranges for fIprocfR to be invoked
- by fBTcl_FinalizeThreadfR and fBTcl_ExitThreadfR.
- This provides a hook for cleanup operations such as flushing buffers
- and freeing global memory.
- fIProcfR should match the type fBTcl_ExitProcfR:
- .CS
- typedef void Tcl_ExitProc(ClientData fIclientDatafR);
- .CE
- The fIclientDatafR parameter to fIprocfR is a
- copy of the fIclientDatafR argument given to
- fBTcl_CreateExitHandlerfR or fBTcl_CreateThreadExitHandlerfR when
- the callback
- was created. Typically, fIclientDatafR points to a data
- structure containing application-specific information about
- what to do in fIprocfR.
- .PP
- fBTcl_DeleteExitHandlerfR and fBTcl_DeleteThreadExitHandlerfR may be
- called to delete a
- previously-created exit handler. It removes the handler
- indicated by fIprocfR and fIclientDatafR so that no call
- to fIprocfR will be made. If no such handler exists then
- fBTcl_DeleteExitHandlerfR or fBTcl_DeleteThreadExitHandlerfR does nothing.
- .PP
- .VS
- .PP
- fBTcl_FinalizefR and fBTcl_ExitfR 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 fBAfR loads extension fBBfR, it usually
- unloads fBBfR before it itself is unloaded.
- If extension fBAfR registers its exit handlers before loading extension
- fBBfR, this ensures that any exit handlers for fBBfR will be executed
- before the exit handlers for fBAfR.
- .VE
- .VS
- .PP
- fBTcl_FinalizefR and fBTcl_ExitfR call fBTcl_FinalizeThreadfR
- and the thread exit handlers fIafterfR
- the process-wide exit handlers. This is because thread finalization shuts
- down the I/O channel system, so any attempt at I/O by the global exit
- handlers will vanish into the bitbucket.
- .VE
- .SH KEYWORDS
- callback, cleanup, dynamic loading, end application, exit, unloading, thread