diff options
author | ferrieux <ferrieux@users.sourceforge.net> | 2009-11-11 00:04:27 (GMT) |
---|---|---|
committer | ferrieux <ferrieux@users.sourceforge.net> | 2009-11-11 00:04:27 (GMT) |
commit | 7e03eeddb9deb973943fe3fe08f6cb60eea084dd (patch) | |
tree | 09de7ae1e3d8746aa5d6fc3ef0884d85234fb8be | |
parent | fe29a271ae36303b08f0638264a0dca9bbaa114d (diff) | |
download | tcl-7e03eeddb9deb973943fe3fe08f6cb60eea084dd.zip tcl-7e03eeddb9deb973943fe3fe08f6cb60eea084dd.tar.gz tcl-7e03eeddb9deb973943fe3fe08f6cb60eea084dd.tar.bz2 |
Backported fix for [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.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | generic/tclIO.c | 17 |
2 files changed, 22 insertions, 2 deletions
@@ -1,3 +1,10 @@ +2009-11-11 Alexandre Ferrieux <ferrieux@users.sourceforge.net> + + * generic/tclIO.c: Backported fix for [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 Don Porter <dgp@users.sourceforge.net> * generic/tclBasic.c: Plug another leak in TCL_EVAL_DIRECT diff --git a/generic/tclIO.c b/generic/tclIO.c index fe5ea86..2b57079 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.137.2.13 2009/10/23 19:09:02 andreas_kupries Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.137.2.14 2009/11/11 00:04:27 ferrieux Exp $ */ #include "tclInt.h" @@ -2922,6 +2922,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; @@ -2963,10 +2964,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. @@ -3045,6 +3050,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; } |