summaryrefslogtreecommitdiffstats
path: root/generic/tclEvent.c
diff options
context:
space:
mode:
authorferrieux <ferrieux@users.sourceforge.net>2011-08-09 17:19:33 (GMT)
committerferrieux <ferrieux@users.sourceforge.net>2011-08-09 17:19:33 (GMT)
commite83ec9b8978e9e4481a549283c64e11f2a1e4a61 (patch)
tree82fd16a3ebffc1553c7b6bb3847e036f9fd6cc61 /generic/tclEvent.c
parent653f52ba6008466571d283d523272ae22c2cf2c4 (diff)
downloadtcl-e83ec9b8978e9e4481a549283c64e11f2a1e4a61.zip
tcl-e83ec9b8978e9e4481a549283c64e11f2a1e4a61.tar.gz
tcl-e83ec9b8978e9e4481a549283c64e11f2a1e4a61.tar.bz2
[Bug 2919042] Restore "valgrindability" of Tcl that was lost by the streamlining of [exit], by conditionally forcing a full Finalize: use -DPURIFY or ::env(TCL_FINALIZE_ON_EXIT)
Diffstat (limited to 'generic/tclEvent.c')
-rw-r--r--generic/tclEvent.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/generic/tclEvent.c b/generic/tclEvent.c
index 6816487..e65862c 100644
--- a/generic/tclEvent.c
+++ b/generic/tclEvent.c
@@ -953,27 +953,38 @@ Tcl_Exit(
currentAppExitPtr(INT2PTR(status));
Tcl_Panic("AppExitProc returned unexpectedly");
} else {
- /*
- * Use default handling.
- */
- InvokeExitHandlers();
+ if (TclFullFinalizationRequested()) {
- /*
- * Ensure the thread-specific data is initialised as it is used in
- * Tcl_FinalizeThread()
- */
-
- (void) TCL_TSD_INIT(&dataKey);
-
- /*
- * Now finalize the calling thread only (others are not safely
- * reachable). Among other things, this triggers a flush of the
- * Tcl_Channels that may have data enqueued.
- */
-
- Tcl_FinalizeThread();
-
+ /*
+ * Thorough finalization for Valgrind et al.
+ */
+
+ Tcl_Finalize();
+
+ } else {
+
+ /*
+ * Fast and deterministic exit (default behavior)
+ */
+
+ InvokeExitHandlers();
+
+ /*
+ * Ensure the thread-specific data is initialised as it is used in
+ * Tcl_FinalizeThread()
+ */
+
+ (void) TCL_TSD_INIT(&dataKey);
+
+ /*
+ * Now finalize the calling thread only (others are not safely
+ * reachable). Among other things, this triggers a flush of the
+ * Tcl_Channels that may have data enqueued.
+ */
+
+ Tcl_FinalizeThread();
+ }
TclpExit(status);
Tcl_Panic("OS exit failed!");
}