Source Files
- portions of tclEvent.c
Public Interface
- Tcl_CreateExitHandler
- Tcl_DeleteExitHandler
- Tcl_CreateThreadExitHandler
- Tcl_DeleteThreadExitHandler
- Tcl_SetExitProc
- Tcl_Exit
- Tcl_Finalize
- Tcl_FinalizeThread
Private Interface
- TclCreateLateExitHandler
- TclDeleteLateExitHandler
- TclInitSubsystems
- TclInExit
- TclInThreadExit
Configuration Defines
TCL_FINALIZE_ON_EXIT
- When defined, free all memory on exit, despite the OS cleaning up after anyway. This reduces reports of false resource leaks for both dynamic and static memory trackers (valgrind, coverity). Note that for dynamic memory tracking it is best to also arrange for the builtinexit
to be a no-op, i.e.proc exit args {}
.
Directly Depends On Public Interface
- just about everything
Directly Depends On Private Interface of
- just about everything
Discussion
This module is devoted to control over the initialization and finalization of the subsystems of Tcl, and extensions to it by way of exit handlers and thread exit handlers. This is the part that could use a good audit and reform, particularly in examining multi-threaded finalization.
The routine TclInitSubsystems needs to become public, so that Tcl using apps can bring up and tear down the Tcl library via an approved set of routines.
It may be that the TclIn(Thread)Exit routines are needed by extensions as well. Or as an alternative, it would be nice if Tcl finalization were well-behaved enough that nothing else had to care whether or not they were running "in exit".