From dd923910369e52da6fd8722fd0f878efa10f0e4f Mon Sep 17 00:00:00 2001 From: Sidharth Kshatriya Date: Mon, 15 Nov 2021 02:44:18 +0530 Subject: [PATCH] Fixes #4432: JSON UI only shows stdin when connecting to an existing session Only ui type Terminal is intended to be a user interactive session. If your ui type is not Terminal, don't worry about making the tty your stdin if fd 0 is not a tty. This allows json-rpc commands sent via stdin to be acted up rather than sent to a fifo (which is the default behavior for kakoune). Does not change the behavior for Terminal ui sessions --- src/main.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cc b/src/main.cc index 6da6e648..e078efc5 100644 --- a/src/main.cc +++ b/src/main.cc @@ -692,7 +692,11 @@ int run_client(StringView session, StringView name, StringView client_init, try { Optional stdin_fd; - if (not isatty(0)) + // json-ui (or dummy) is not intended to be user interactive. + // So only worry about making the tty your stdin if: + // (a) ui_type is Terminal, *and* + // (b) fd 0 is not interactive. + if (ui_type == UIType::Terminal && not isatty(0)) { // move stdin to another fd, and restore tty as stdin stdin_fd = dup(0);