summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclIO.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 3815c66..affa03b 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIO.c,v 1.155 2008/12/18 01:14:16 ferrieux Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.156 2008/12/18 16:52:53 ferrieux Exp $
*/
#include "tclInt.h"
@@ -3166,6 +3166,21 @@ Tcl_CloseEx(
return TCL_ERROR;
}
+ /*
+ * Flush any data if [close w]
+ */
+
+ if (flags & TCL_CLOSE_WRITE) {
+ if ((statePtr->curOutPtr != NULL) && IsBufferReady(statePtr->curOutPtr)) {
+ SetFlag(statePtr, BUFFER_READY);
+ }
+ /*
+ * Ignoring the outcome of the flush (like EPIPE), since we don't want
+ * to disrupt the close path with such errors
+ */
+ FlushChannel(NULL, chanPtr, 0);
+ }
+
/*
* Finally do what is asked of us.
*/