Subject: Set return message in close if a flush error is reported (which may be an error from a background flush). Ticket [97069ea11a]

From: oehhar <[email-masked]>
Date: Tue, 1 Apr 2014 09:52:34 +0000

---
 generic/tclIO.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/generic/tclIO.c b/generic/tclIO.c
index c43e61e..15fc8af 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -3209,9 +3209,20 @@ Tcl_Close(
 	    Tcl_SetObjResult(interp,
 			     Tcl_NewStringObj(Tcl_PosixError(interp), -1));
 	}
-	flushcode = -1;
+	return TCL_ERROR;
     }
-    if ((flushcode != 0) || (result != 0)) {
+    if (result != 0) {
+	return TCL_ERROR;
+    }
+    /*
+     * Bug 97069ea11a: set error message if a flush code is set
+     */
+    if (flushcode != 0) {
+	Tcl_SetErrno(flushcode);
+	if (interp != NULL) {
+	    Tcl_SetObjResult(interp,
+			     Tcl_NewStringObj(Tcl_PosixError(interp), -1));
+	}
 	return TCL_ERROR;
     }
     return TCL_OK;
-- 
cgit v0.12