From 69e155a5691d03e8293409bdc307651f0c92494e Mon Sep 17 00:00:00 2001 From: ferrieux Date: Tue, 10 Nov 2009 23:50:17 +0000 Subject: Fix [Bug 2888099] (close discards ENOSPC error) by saving the errno from the first of two FlushChannel()s. Uneasy to test; might need specific channel drivers. Four-hands with aku. --- ChangeLog | 7 +++++++ generic/tclIO.c | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b7fd4b..163babe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-11-11 Alexandre Ferrieux + + * generic/tclIO.c: Fix [Bug 2888099] (close discards ENOSPC error) + by saving the errno from the first of two + FlushChannel()s. Uneasy to test; might need + specific channel drivers. Four-hands with aku. + 2009-11-10 Pat Thoyts * tests/winFCmd.test: Cleanup directories that have been set chmod diff --git a/generic/tclIO.c b/generic/tclIO.c index 439eac2..e295c82 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.165 2009/11/09 13:47:23 dkf Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.166 2009/11/10 23:50:17 ferrieux Exp $ */ #include "tclInt.h" @@ -2976,6 +2976,7 @@ Tcl_Close( ChannelState *statePtr; /* State of real IO channel. */ int result; /* Of calling FlushChannel. */ int flushcode; + int stickyError; if (chan == NULL) { return TCL_OK; @@ -3017,10 +3018,14 @@ Tcl_Close( * iso2022, the terminated escape sequence must write to the buffer. */ + stickyError = 0; + if ((statePtr->encoding != NULL) && (statePtr->curOutPtr != NULL) && (CheckChannelErrors(statePtr, TCL_WRITABLE) == 0)) { statePtr->outputEncodingFlags |= TCL_ENCODING_END; - WriteChars(chanPtr, "", 0); + if (WriteChars(chanPtr, "", 0) < 0) { + stickyError = Tcl_GetErrno(); + } /* * TIP #219, Tcl Channel Reflection API. @@ -3099,6 +3104,14 @@ Tcl_Close( result = EINVAL; } + if (stickyError != 0) { + Tcl_SetErrno(stickyError); + if (interp != NULL) { + Tcl_SetObjResult(interp, + Tcl_NewStringObj(Tcl_PosixError(interp), -1)); + } + flushcode = -1; + } if ((flushcode != 0) || (result != 0)) { return TCL_ERROR; } @@ -11195,5 +11208,7 @@ DumpFlags( * mode: c * c-basic-offset: 4 * fill-column: 78 + * tab-width: 8 + * indent-tabs-mode: nil * End: */ -- cgit v0.12