From 90456a5717ca6ab20750eba147d692ee4cbfb2f0 Mon Sep 17 00:00:00 2001 From: brian khuu Date: Tue, 21 May 2024 04:57:26 +1000 Subject: [PATCH] main: only merge stdout and control token if not in conversation or grammar mode --- examples/main/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/main/main.cpp b/examples/main/main.cpp index aded5bbf1..66f6695b7 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -531,9 +531,10 @@ int main(int argc, char ** argv) { } #ifndef _MSC_VER - if (fcntl(CONTROL_TOKEN_FILENO, F_GETFL) == -1) { - // Control Token File Descriptor has nothing attached to it - // make control token file descriptor be an alias of stdout + const bool control_token_descriptor_is_attached = fcntl(CONTROL_TOKEN_FILENO, F_GETFL) != -1; + if (!control_token_descriptor_is_attached && !params.conversation && sparams.grammar.empty()) { + // Control Token File Descriptor has nothing attached to it so make control token file descriptor be an alias of stdout + // This is not done however if we are in conversation mode or grammar mode as that is typically discarded dup2(STDOUT_FILENO, CONTROL_TOKEN_FILENO); } #endif