diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2015-09-24 13:48:37 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2015-09-24 13:48:37 (GMT) |
commit | 6f3388528ef453d29fbddba3f5a054d2f5268207 (patch) | |
tree | 51b638cc0fe1a9d9ca7a4590d9eb8d38b6f79307 /win/tclWinConsole.c | |
parent | bf1e2150cc603698bc042d0552c49930e86b2ca9 (diff) | |
parent | f9465250b939d54021e85ba03eaf63f31b4b3037 (diff) | |
download | tcl-6f3388528ef453d29fbddba3f5a054d2f5268207.zip tcl-6f3388528ef453d29fbddba3f5a054d2f5268207.tar.gz tcl-6f3388528ef453d29fbddba3f5a054d2f5268207.tar.bz2 |
merge trunk
Diffstat (limited to 'win/tclWinConsole.c')
-rw-r--r-- | win/tclWinConsole.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c index 65e4aed..ab55035 100644 --- a/win/tclWinConsole.c +++ b/win/tclWinConsole.c @@ -220,8 +220,20 @@ ReadConsoleBytes( BOOL result; int tcharsize = sizeof(TCHAR); - result = ReadConsole(hConsole, lpBuffer, nbytes / tcharsize, &ntchars, - NULL); + /* + * If user types a Ctrl-Break or Ctrl-C, ReadConsole will return + * success with ntchars == 0 and GetLastError() will be + * ERROR_OPERATION_ABORTED. We do not want to treat this case + * as EOF so we will loop around again. If no Ctrl signal handlers + * have been established, the default signal OS handler in a separate + * thread will terminate the program. If a Ctrl signal handler + * has been established (through an extension for example), it + * will run and take whatever action it deems appropriate. + */ + do { + result = ReadConsole(hConsole, lpBuffer, nbytes / tcharsize, &ntchars, + NULL); + } while (result && ntchars == 0 && GetLastError() == ERROR_OPERATION_ABORTED); if (nbytesread != NULL) { *nbytesread = ntchars * tcharsize; } @@ -756,6 +768,13 @@ ConsoleInputProc( if (ReadConsoleBytes(infoPtr->handle, (LPVOID) buf, (DWORD) bufSize, &count) == TRUE) { + /* + * TODO: This potentially writes beyond the limits specified + * by the caller. In practice this is harmless, since all writes + * are into ChannelBuffers, and those have padding, but still + * ought to remove this, unless some Windows wizard can give + * a reason not to. + */ buf[count] = '\0'; return count; } @@ -800,7 +819,7 @@ ConsoleOutputProc( * the channel is in non-blocking mode. */ - errno = EAGAIN; + errno = EWOULDBLOCK; goto error; } @@ -1079,7 +1098,7 @@ WaitForRead( * is in non-blocking mode. */ - errno = EAGAIN; + errno = EWOULDBLOCK; return -1; } |