📄 exit.3
字号:
'\"'\" 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 NAMETcl_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_Exit\fR(\fIstatus\fR).sp\fBTcl_Finalize\fR().sp\fBTcl_CreateExitHandler\fR(\fIproc, clientData\fR).sp\fBTcl_DeleteExitHandler\fR(\fIproc, clientData\fR).sp\fBTcl_ExitThread\fR(\fIstatus\fR).sp\fBTcl_FinalizeThread\fR().sp\fBTcl_CreateThreadExitHandler\fR(\fIproc, clientData\fR).sp\fBTcl_DeleteThreadExitHandler\fR(\fIproc, clientData\fR).SH ARGUMENTS.AS Tcl_ExitProc clientData.AP int status inProvides information about why the application or thread exited.Exact meaning maybe platform-specific. 0 usually means a normal exit, any nonzero valueusually means that an error occurred..AP Tcl_ExitProc *proc inProcedure to invoke before exiting application..AP ClientData clientData inArbitrary one-word value to pass to \fIproc\fR..BE.SH DESCRIPTION.PPThe procedures described here provide a graceful mechanism to end theexecution of a \fBTcl\fR application. Exit handlers are invoked to cleanup theapplication's state before ending the execution of \fBTcl\fR code..PPInvoke \fBTcl_Exit\fR to end a \fBTcl\fR application and to exit from thisprocess. This procedure is invoked by the \fBexit\fR command, and can beinvoked anyplace else to terminate the application.No-one should ever invoke the \fBexit\fR system procedure directly; alwaysinvoke \fBTcl_Exit\fR instead, so that it can invoke exit handlers.Note that if other code invokes \fBexit\fR system procedure directly, orotherwise causes the application to terminate without calling\fBTcl_Exit\fR, the exit handlers will not be run.\fBTcl_Exit\fR internally invokes the \fBexit\fR system call, thus it neverreturns control to its caller..PP\fBTcl_Finalize\fR is similar to \fBTcl_Exit\fR except that it does notexit from the current process.It is useful for cleaning up when a process is finished using \fBTcl\fR butwishes to continue executing, and when \fBTcl\fR is used in a dynamicallyloaded extension that is about to be unloaded.On some systems \fBTcl\fR is automatically notified when it is beingunloaded, and it calls \fBTcl_Finalize\fR internally; on these systems itnot necessary for the caller to explicitly call \fBTcl_Finalize\fR.However, to ensure portability, your code should always invoke\fBTcl_Finalize\fR when \fBTcl\fR is being unloaded, to ensure that thecode will work on all platforms. \fBTcl_Finalize\fR can be safely calledmore than once..PP.VS\fBTcl_ExitThread\fR is used to terminate the current thread and invokeper-thread exit handlers. This finalization is done by\fBTcl_FinalizeThread\fR, which you can call if you just want to cleanup per-thread state and invoke the thread exit handlers.\fBTcl_Finalize\fR calls \fBTcl_FinalizeThread\fR for the currentthread automatically..VE.PP\fBTcl_CreateExitHandler\fR arranges for \fIproc\fR to be invokedby \fBTcl_Finalize\fR and \fBTcl_Exit\fR.\fBTcl_CreateThreadExitHandler\fR arranges for \fIproc\fR to be invokedby \fBTcl_FinalizeThread\fR and \fBTcl_ExitThread\fR.This provides a hook for cleanup operations such as flushing buffersand freeing global memory.\fIProc\fR should match the type \fBTcl_ExitProc\fR:.CStypedef void Tcl_ExitProc(ClientData \fIclientData\fR);.CEThe \fIclientData\fR parameter to \fIproc\fR is acopy of the \fIclientData\fR argument given to\fBTcl_CreateExitHandler\fR or \fBTcl_CreateThreadExitHandler\fR whenthe callbackwas created. Typically, \fIclientData\fR points to a datastructure containing application-specific information aboutwhat to do in \fIproc\fR..PP\fBTcl_DeleteExitHandler\fR and \fBTcl_DeleteThreadExitHandler\fR may becalled to delete apreviously-created exit handler. It removes the handlerindicated by \fIproc\fR and \fIclientData\fR so that no callto \fIproc\fR will be made. If no such handler exists then\fBTcl_DeleteExitHandler\fR or \fBTcl_DeleteThreadExitHandler\fR does nothing..PP.VS.PP\fBTcl_Finalize\fR and \fBTcl_Exit\fR 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 \fBA\fR loads extension \fBB\fR, it usuallyunloads \fBB\fR before it itself is unloaded.If extension \fBA\fR registers its exit handlers before loading extension\fBB\fR, this ensures that any exit handlers for \fBB\fR will be executedbefore the exit handlers for \fBA\fR..VE.VS.PP\fBTcl_Finalize\fR and \fBTcl_Exit\fR call \fBTcl_FinalizeThread\fR and the thread exit handlers \fIafter\fRthe process-wide exit handlers. This is because thread finalization shutsdown the I/O channel system, so any attempt at I/O by the global exithandlers will vanish into the bitbucket..VE.SH KEYWORDScallback, cleanup, dynamic loading, end application, exit, unloading, thread
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -