From 20c7877dcb0aba0a198ea3e66b29f72cc5e8de85 Mon Sep 17 00:00:00 2001 From: AlanKingPL Date: Wed, 8 Jul 2026 13:13:40 +0200 Subject: [PATCH] terminal: Enhance terminal size detection for multiple outputs - Get the terminal size from STDOUT or STDERR when the terminal size of STDIN is not available. Closes https://github.com/curl/curl/pull/22276 --- src/terminal.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/terminal.c b/src/terminal.c index b25c0e6e80..2e28d92323 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -62,6 +62,10 @@ unsigned int get_terminal_columns(void) struct winsize ts; if(!ioctl(STDIN_FILENO, TIOCGWINSZ, &ts)) cols = (int)ts.ws_col; + else if(!ioctl(STDOUT_FILENO, TIOCGWINSZ, &ts)) + cols = (int)ts.ws_col; + else if(!ioctl(STDERR_FILENO, TIOCGWINSZ, &ts)) + cols = (int)ts.ws_col; #elif defined(_WIN32) && !defined(CURL_WINDOWS_UWP) { HANDLE stderr_hnd = GetStdHandle(STD_ERROR_HANDLE);