Tcl_Exit


HOME

Tcl_Exit

NAME
SYNOPSIS
ARGUMENTS
DESCRIPTION
KEYWORDS

___________________________

NAME

Tcl_Exit, Tcl_Finalize, Tcl_CreateExitHandler, Tcl_DeleteExitHandler, Tcl_ExitThread, Tcl_FinalizeThread, Tcl_CreateThreadExitHandler, Tcl_DeleteThreadExitHandler, Tcl_SetExitProc − end the application or thread (and invoke exit handlers)

SYNOPSIS

#include <tcl.h>

Tcl_Exit(status)

Tcl_Finalize()

Tcl_CreateExitHandler(proc, clientData)

Tcl_DeleteExitHandler(proc, clientData)

Tcl_ExitThread(status)

Tcl_FinalizeThread()

Tcl_CreateThreadExitHandler(proc, clientData)

Tcl_DeleteThreadExitHandler(proc, clientData)

Tcl_ExitProc * │
Tcl_SetExitProc
(proc) │

ARGUMENTS

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.

Tcl_ExitProc *proc (in)

Procedure to invoke before exiting application, or (for Tcl_SetExitProc) NULL to uninstall the current application exit procedure.

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. If an application exit handler has been │ installed (see Tcl_SetExitProc), that handler is invoked with an │ argument consisting of the exit status (cast to ClientData); the │ application exit handler should not return control to Tcl.

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_ExitThread is used to terminate the current thread and invoke per-thread exit handlers. This finalization is done by Tcl_FinalizeThread, which you can call if you just want to clean up per-thread state and invoke the thread exit handlers. Tcl_Finalize calls Tcl_FinalizeThread for the current thread automatically.

Tcl_CreateExitHandler arranges for proc to be invoked by Tcl_Finalize and Tcl_Exit. Tcl_CreateThreadExitHandler arranges for proc to be invoked by Tcl_FinalizeThread and Tcl_ExitThread. 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 or Tcl_CreateThreadExitHandler when the callback was created. Typically, clientData points to a data structure containing application-specific information about what to do in proc.

Tcl_DeleteExitHandler and Tcl_DeleteThreadExitHandler 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 or Tcl_DeleteThreadExitHandler 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.

Tcl_Finalize and Tcl_Exit call Tcl_FinalizeThread and the thread exit handlers after 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.

Tcl_SetExitProc installs an application exit handler, returning the │ previously-installed application exit handler or NULL if no application │ handler was installed. If an application exit handler is installed, │ that exit handler takes over complete responsibility for finalization │ of Tcl’s subsystems via Tcl_Finalize at an appropriate time. The │ argument passed to proc when it is invoked will be the exit status code │ (as passed to Tcl_Exit) cast to a ClientData value.

KEYWORDS

callback, cleanup, dynamic loading, end application, exit, unloading, thread



More Linux Commands

manpages/fegetexceptflag.3.html
fegetexceptflag(3) - floating-point rounding and exception h
These eleven functions were defined in C99, and describe the handling of floating-point rounding and exceptions (overflow, zero-divide, etc.). Exceptions The di

manpages/SelfLoader.3pm.html
SelfLoader(3pm) - load functions only on demand (Man Page)
This module tells its users that functions in the FOOBAR package are to be autoloaded from after the __DATA__ token. See also Autoloading in perlsub. The __DATA

manpages/acl.5.html
acl(5) - Access Control Lists (Formats - Linux man page)....
This manual page describes POSIX Access Control Lists, which are used to define more fine-grained discretionary access rights for files and directories. ACL TYP

manpages/Tcl_ConvertCountedElement.3.html
Tcl_ConvertCountedElement(3) - manipulate Tcl lists.........
These procedures may be used to disassemble and reassemble Tcl lists. Tcl_SplitList breaks a list up into its constituent elements, returning an array of pointe

manpages/clear.1.html
clear(1) - clear the terminal screen - Linux manual page....
clear clears your screen if this is possible, including its scrollback buffer (if the extended E3 capability is defined). clear looks in the environment for the

manpages/Keylist.3.html
Keylist(3) - Keyed list management routines. (Man Page).....
These routines perform operations on keyed lists. See the Extended Tcl man page for a description of keyed lists. TclX_NewKeyedListObj Create and initialize a n

manpages/XmbufChangeBufferAttributes.3.html
XmbufChangeBufferAttributes(3) - X multibuffering functions
XmbufChangeBufferAttributes.3 - The application programming library for the X11 Double-Buffering, Multi-Buffering, and Stereo Extension contains the interfaces

manpages/gorbd.1.html
gorbd(1) - - An object request broker daemon (Man Page).....
To be written ... OPTIONS -ORBInitialPort PORT Port on which persistent naming service is to be started. -ior FILE File in which to store persistent naming serv

manpages/Tcl_ChannelHandlerProc.3.html
Tcl_ChannelHandlerProc(3) - procedures for creating and mani
Tcl uses a two-layered channel architecture. It provides a generic upper layer to enable C and Tcl programs to perform input and output using the same APIs for

manpages/mautil.1.html
mautil(1) - Mono.Addins Setup Utility - Linux manual page...
The mautil tool works with Mono.Addins repositories and packages. OPTIONS --registry, -reg Specify add-in registry path --path, -p Specify startup path -v Verbo

manpages/mount.nfs.8.html
mount.nfs(8) - mount a Network File System - Linux man page
mount.nfs is a part of nfs(5) utilities package, which provides NFS client functionality. mount.nfs is meant to be used by the mount(8) command for mounting NFS

manpages/exp10l.3.html
exp10l(3) - base-10 exponential function - Linux man page...
The exp10() function returns the value of 10 raised to the power of x. RETURN VALUE On success, these functions return the base-10 exponential value of x. For v





We can't live, work or learn in freedom unless the software we use is free.