summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorvasiljevic <zv@archiware.com>2005-07-01 10:57:56 (GMT)
committervasiljevic <zv@archiware.com>2005-07-01 10:57:56 (GMT)
commit50c7a2cc2c47a7ed8baf68660b8121d73615dd5f (patch)
tree1dab5e9dc4aa9d4fc7349ebd603df31bfa57c559 /unix
parent6cbb04c3fbe6a85d1d6f804276f6fc213ce9d2ab (diff)
downloadtcl-50c7a2cc2c47a7ed8baf68660b8121d73615dd5f.zip
tcl-50c7a2cc2c47a7ed8baf68660b8121d73615dd5f.tar.gz
tcl-50c7a2cc2c47a7ed8baf68660b8121d73615dd5f.tar.bz2
Protect against spurious wake-ups while waiting on the condition variable
when tearing down the notifier thread [Bug# 1222872].
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixNotfy.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index 1f1615d..24d552f 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixNotfy.c,v 1.11.2.12 2005/06/07 10:26:58 dkf Exp $
+ * RCS: @(#) $Id: tclUnixNotfy.c,v 1.11.2.13 2005/07/01 10:57:59 vasiljevic Exp $
*/
#ifndef HAVE_COREFOUNDATION /* Darwin/Mac OS X CoreFoundation notifier
@@ -275,7 +275,7 @@ Tcl_FinalizeNotifier(clientData)
*/
if (notifierCount == 0) {
- int result, dummy;
+ int result;
if (triggerPipe < 0) {
panic("Tcl_FinalizeNotifier: notifier pipe not initialized");
}
@@ -288,13 +288,15 @@ Tcl_FinalizeNotifier(clientData)
* not just close the pipe and check for EOF in the notifier
* thread because if a background child process was created with
* exec, select() would not register the EOF on the pipe until the
- * child processes had terminated. [Bug: 4139]
+ * child processes had terminated. [Bug: 4139] [Bug: 1222872]
*/
+
write(triggerPipe, "q", 1);
close(triggerPipe);
-
- Tcl_ConditionWait(&notifierCV, &notifierMutex, NULL);
- result = Tcl_JoinThread(notifierThread, &dummy);
+ while(triggerPipe >= 0) {
+ Tcl_ConditionWait(&notifierCV, &notifierMutex, NULL);
+ }
+ result = Tcl_JoinThread(notifierThread, NULL);
if (result) {
Tcl_Panic("Tcl_FinalizeNotifier: unable to join notifier thread");
}