summaryrefslogtreecommitdiffstats
path: root/win/tclWinPipe.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-07-31 11:00:25 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-07-31 11:00:25 (GMT)
commitddad954e2df0db369c13c4c39d647a2c4abd67da (patch)
treef8b70029a1b0635ea9c4954f14d160d90c3fb0ff /win/tclWinPipe.c
parent0a213115cc2d64e0bf3608839b2b3f079e89c04e (diff)
parentcb75a6048aea230290902a214ce83d0a75e30a30 (diff)
downloadtcl-ddad954e2df0db369c13c4c39d647a2c4abd67da.zip
tcl-ddad954e2df0db369c13c4c39d647a2c4abd67da.tar.gz
tcl-ddad954e2df0db369c13c4c39d647a2c4abd67da.tar.bz2
merge trunkbug_3545363
Diffstat (limited to 'win/tclWinPipe.c')
-rw-r--r--win/tclWinPipe.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index cc696a2..f36f797 100644
--- a/win/tclWinPipe.c
+++ b/win/tclWinPipe.c
@@ -1875,12 +1875,26 @@ PipeClose2Proc(
&& (pipePtr->writeFile != NULL)) {
if (pipePtr->writeThread) {
/*
- * Wait for the writer thread to finish the current buffer, then
- * terminate the thread and close the handles. If the channel is
- * nonblocking, there should be no pending write operations.
+ * Wait for the writer thread to finish the current buffer, then
+ * terminate the thread and close the handles. If the channel is
+ * nonblocking but blocked during exit, bail out since the worker
+ * thread is not interruptible and we want TIP#398-fast-exit.
*/
+ if (TclInExit()
+ && (pipePtr->flags & PIPE_ASYNC)) {
- WaitForSingleObject(pipePtr->writable, INFINITE);
+ /* give it a chance to leave honorably */
+ SetEvent(pipePtr->stopWriter);
+
+ if (WaitForSingleObject(pipePtr->writable, 0) == WAIT_TIMEOUT) {
+ return EAGAIN;
+ }
+
+ } else {
+
+ WaitForSingleObject(pipePtr->writable, INFINITE);
+
+ }
/*
* The thread may already have closed on it's own. Check its exit
@@ -2945,6 +2959,10 @@ PipeWriterThread(
* an error, so exit.
*/
+ if (waitResult == WAIT_OBJECT_0) {
+ SetEvent(infoPtr->writable);
+ }
+
break;
}