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
This commit is contained in:
AlanKingPL 2026-07-08 13:13:40 +02:00 committed by Jay Satiro
parent a479459ea3
commit 20c7877dcb

View file

@ -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);