]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
terminal: Enhance terminal size detection for multiple outputs master 22276/head
authorAlanKingPL <alankingpl0@gmail.com>
Wed, 8 Jul 2026 11:13:40 +0000 (13:13 +0200)
committerJay Satiro <raysatiro@yahoo.com>
Fri, 24 Jul 2026 15:46:54 +0000 (11:46 -0400)
- 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

index b25c0e6e80063cfc9a581a7a3ee81846809427c3..2e28d9232309e1fa723e08f7afc6822ae540f8b1 100644 (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);