From 404238ca7e941ab1baf288c6b14b1f5acdec0643 Mon Sep 17 00:00:00 2001 From: ferrieux Date: Thu, 18 Dec 2008 16:52:53 +0000 Subject: Add missing flush for half-close of the write side --- generic/tclIO.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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. */ -- cgit v0.12