Attachment "flush3.patch" to
ticket [525783ffff]
added by
dkf
2002-03-05 23:40:48.
--- /home/fellowsd/lang/tcl/cvs/tcl/unix/tclUnixChan.c Thu Feb 28 14:26:21 2002
+++ tclUnixChan.c Tue Mar 5 16:28:38 2002
@@ -669,11 +669,17 @@
ClientData instanceData; /* Tty state. */
Tcl_Interp *interp; /* For error reporting - unused. */
{
- TtyState *ttyPtr;
+ TtyState *ttyPtr = (TtyState *) instanceData;
- ttyPtr = (TtyState *) instanceData;
+ /*
+ * Only hard-flush channels that are not stdout and not stderr,
+ * otherwise debugging output sent to terminals can get lost!
+ * Tcl bug #525783
+ */
#ifdef TTYFLUSH
- TTYFLUSH(ttyPtr->fs.fd);
+ if (ttyPtr->fs.fd!=0 && ttyPtr->fs.fd!=1 && ttyPtr->fs.fd!=2) {
+ TTYFLUSH(ttyPtr->fs.fd);
+ }
#endif
#if 0
/*
@@ -720,10 +726,14 @@
int toWrite; /* How many bytes to write? */
int *errorCodePtr; /* Where to store error code. */
{
- if ( TclInExit() ) {
+ TtyState *ttyPtr = (TtyState *) instanceData;
+
+ if (ttyPtr->fs.fd!=1 && ttyPtr->fs.fd!=2 && TclInExit()) {
/*
- * Do not write data during Tcl exit.
- * Serial port may block preventing Tcl from exit.
+ * Do not write data during Tcl exit (except to stdout and
+ * stderr.) Serial port may block preventing Tcl from exit.
+ * Note that stdout and stderr are excepted because of the
+ * impact on interactive debugging...
*/
return toWrite;
} else {