From 247b78e04059c63bb74ad0cc3bb81f93e0636b95 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 7 Feb 2014 09:48:31 +0100 Subject: [PATCH] When ICS Console open EOF from keyboard is no error In case the user started without a terminal, we just close the input source, and suppress future writing to the xterm. --- gtk/xboard.c | 5 +++++ usystem.c | 8 +++++--- usystem.h | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gtk/xboard.c b/gtk/xboard.c index aff56cc..8537eaf 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -1970,6 +1970,11 @@ DoInputCallback(io, cond, data) count = read(is->fd, is->unused, INPUT_SOURCE_BUF_SIZE - (is->unused - is->buf)); if (count <= 0) { + if(count == 0 && is->kind == CPReal && shells[ChatDlg]) { // [HGM] absence of terminal is no error if ICS Console present + RemoveInputSource(is); // cease reading stdin + stdoutClosed = TRUE; // suppress future output + return True; + } (is->func)(is, is->closure, is->buf, count, count ? errno : 0); return True; } diff --git a/usystem.c b/usystem.c index 4a08e57..9223480 100644 --- a/usystem.c +++ b/usystem.c @@ -650,6 +650,8 @@ OpenRcmd (char *host, char *user, char *cmd, ProcRef *pr) return -1; } +Boolean stdoutClosed = FALSE; + int OutputToProcess (ProcRef pr, char *message, int count, int *outError) { @@ -659,9 +661,9 @@ OutputToProcess (ProcRef pr, char *message, int count, int *outError) if (pr == NoProc) { - if (appData.noJoin || !appData.useInternalWrap) - outCount = fwrite(message, 1, count, stdout); - else + if (appData.noJoin || !appData.useInternalWrap) { + if(!stdoutClosed) outCount = fwrite(message, 1, count, stdout); + } else { int width = get_term_width(); int len = wrap(NULL, message, count, width, &line); diff --git a/usystem.h b/usystem.h index b776652..a0acd30 100644 --- a/usystem.h +++ b/usystem.h @@ -68,6 +68,7 @@ typedef struct { } ChildProc; extern char *oldICSInteractionTitle; +extern Boolean stdoutClosed; char *ExpandPathName P((char *path)); int MySearchPath P((char *installDir, char *name, char *fullname)); -- 1.7.0.4