summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixChan.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tclUnixChan.c')
-rw-r--r--unix/tclUnixChan.c127
1 files changed, 5 insertions, 122 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 7e3c507..e0f7761 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.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: tclUnixChan.c,v 1.89 2007/12/13 15:28:42 dgp Exp $
+ * RCS: @(#) $Id: tclUnixChan.c,v 1.90 2008/02/27 03:35:50 jenglish Exp $
*/
#include "tclInt.h" /* Internal definitions for Tcl. */
@@ -65,22 +65,6 @@
# define GETCONTROL(fd, intPtr) ioctl((fd), TIOCMGET, (intPtr))
# define SETCONTROL(fd, intPtr) ioctl((fd), TIOCMSET, (intPtr))
- /*
- * TIP #35 introduced a different on exit flush/close behavior that does
- * not work correctly with standard channels on all systems. The problem
- * is tcflush throws away waiting channel data. This may be necessary for
- * true serial channels that may block, but isn't correct in the standard
- * case. This might be replaced with tcdrain instead, but that can block.
- * For now, we revert to making this do nothing, and TtyOutputProc being
- * the same old FileOutputProc. - hobbs [Bug #525783]
- */
-
-# define BAD_TIP35_FLUSH 0
-# if BAD_TIP35_FLUSH
-# define TTYFLUSH(fd) tcflush((fd), TCIOFLUSH);
-# else
-# define TTYFLUSH(fd)
-# endif /* BAD_TIP35_FLUSH */
# ifdef FIONREAD
# define GETREADQUEUE(fd, int) ioctl((fd), FIONREAD, &(int))
# elif defined(FIORDCHK)
@@ -158,8 +142,6 @@ typedef struct FileState {
typedef struct TtyState {
FileState fs; /* Per-instance state of the file descriptor.
* Must be the first field. */
- int stateUpdated; /* Flag to say if the state has been modified
- * and needs resetting. */
IOSTATE savedState; /* Initial state of device. Used to reset
* state when device closed. */
} TtyState;
@@ -270,8 +252,6 @@ static int TcpOutputProc(ClientData instanceData,
const char *buf, int toWrite, int *errorCode);
static void TcpWatchProc(ClientData instanceData, int mask);
#ifdef SUPPORTS_TTY
-static int TtyCloseProc(ClientData instanceData,
- Tcl_Interp *interp);
static void TtyGetAttributes(int fd, TtyAttrs *ttyPtr);
static int TtyGetOptionProc(ClientData instanceData,
Tcl_Interp *interp, const char *optionName,
@@ -282,10 +262,6 @@ static unsigned long TtyGetSpeed(int baud);
#endif /* DIRECT_BAUD */
static FileState * TtyInit(int fd, int initialize);
static void TtyModemStatusStr(int status, Tcl_DString *dsPtr);
-#if BAD_TIP35_FLUSH
-static int TtyOutputProc(ClientData instanceData,
- const char *buf, int toWrite, int *errorCode);
-#endif /* BAD_TIP35_FLUSH */
static int TtyParseMode(Tcl_Interp *interp, const char *mode,
int *speedPtr, int *parityPtr, int *dataPtr,
int *stopPtr);
@@ -331,13 +307,9 @@ static Tcl_ChannelType fileChannelType = {
static Tcl_ChannelType ttyChannelType = {
"tty", /* Type name. */
TCL_CHANNEL_VERSION_5, /* v5 channel */
- TtyCloseProc, /* Close proc. */
+ FileCloseProc, /* Close proc. */
FileInputProc, /* Input proc. */
-#if BAD_TIP35_FLUSH
- TtyOutputProc, /* Output proc. */
-#else /* !BAD_TIP35_FLUSH */
FileOutputProc, /* Output proc. */
-#endif /* BAD_TIP35_FLUSH */
NULL, /* Seek proc. */
TtySetOptionProc, /* Set option proc. */
TtyGetOptionProc, /* Get option proc. */
@@ -738,94 +710,6 @@ FileGetHandleProc(
}
#ifdef SUPPORTS_TTY
-/*
- *----------------------------------------------------------------------
- *
- * TtyCloseProc --
- *
- * This function is called from the generic IO level to perform
- * channel-type-specific cleanup when a tty based channel is closed.
- *
- * Results:
- * 0 if successful, errno if failed.
- *
- * Side effects:
- * Closes the device of the channel.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-TtyCloseProc(
- ClientData instanceData, /* Tty state. */
- Tcl_Interp *interp) /* For error reporting - unused. */
-{
-#if BAD_TIP35_FLUSH
- TtyState *ttyPtr = (TtyState *) instanceData;
-#endif /* BAD_TIP35_FLUSH */
-
-#ifdef TTYFLUSH
- TTYFLUSH(ttyPtr->fs.fd);
-#endif /* TTYFLUSH */
-
-#if 0
- /*
- * TIP#35 agreed to remove the unsave so that TCL could be used as a
- * simple stty. It would be cleaner to remove all the stuff related to
- * TtyState.stateUpdated
- * TtyState.savedState
- * Then the structure TtyState would be the same as FileState. IMO this
- * cleanup could better be done for the final 8.4 release after nobody
- * complained about the missing unsave. - schroedter
- */
- if (ttyPtr->stateUpdated) {
- SETIOSTATE(ttyPtr->fs.fd, &ttyPtr->savedState);
- }
-#endif
-
- return FileCloseProc(instanceData, interp);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TtyOutputProc--
- *
- * This function is invoked from the generic IO level to write output to
- * a TTY channel.
- *
- * Results:
- * The number of bytes written is returned or -1 on error. An output
- * argument contains a POSIX error code if an error occurred, or zero.
- *
- * Side effects:
- * Writes output on the output device of the channel if the channel is
- * not designated to be closed.
- *
- *----------------------------------------------------------------------
- */
-
-#if BAD_TIP35_FLUSH
-static int
-TtyOutputProc(
- ClientData instanceData, /* File state. */
- const char *buf, /* The data buffer. */
- int toWrite, /* How many bytes to write? */
- int *errorCodePtr) /* Where to store error code. */
-{
- if (TclInExit()) {
- /*
- * Do not write data during Tcl exit. Serial port may block preventing
- * Tcl from exit.
- */
-
- return toWrite;
- }
-
- return FileOutputProc(instanceData, buf, toWrite, errorCodePtr);
-}
-#endif /* BAD_TIP35_FLUSH */
-
#ifdef USE_TERMIOS
/*
*----------------------------------------------------------------------
@@ -912,7 +796,6 @@ TtySetOptionProc(
*/
TtySetAttributes(fsPtr->fd, &tty);
- ((TtyState *) fsPtr)->stateUpdated = 1;
return TCL_OK;
}
@@ -1704,10 +1587,10 @@ TtyInit(
int initialize)
{
TtyState *ttyPtr;
+ int stateUpdated = 0;
ttyPtr = (TtyState *) ckalloc((unsigned) sizeof(TtyState));
GETIOSTATE(fd, &ttyPtr->savedState);
- ttyPtr->stateUpdated = 0;
if (initialize) {
IOSTATE iostate = ttyPtr->savedState;
@@ -1718,7 +1601,7 @@ TtyInit(
iostate.c_cflag & CREAD ||
iostate.c_cc[VMIN] != 1 ||
iostate.c_cc[VTIME] != 0) {
- ttyPtr->stateUpdated = 1;
+ stateUpdated = 1;
}
iostate.c_iflag = IGNBRK;
iostate.c_oflag = 0;
@@ -1741,7 +1624,7 @@ TtyInit(
* Only update if we're changing anything to avoid possible blocking.
*/
- if (ttyPtr->stateUpdated) {
+ if (stateUpdated) {
SETIOSTATE(fd, &iostate);
}
}