]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
terminal-util: add recognizable error if cols/rows of tty are initially not initialized
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Jul 2024 15:45:26 +0000 (17:45 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 19 Jul 2024 09:44:04 +0000 (11:44 +0200)
Various tty types come up with cols/rows not initialized (i.e. set to
zero). Let's detect these cases, and return a better error than EIO,
simply to make things easier to debug.

src/basic/terminal-util.c

index df091c36a96bfb99e7568de000049c85f3e81350..c2ff3ca85a8ea5fb246d8ec77edee1c2d905b976 100644 (file)
@@ -855,7 +855,7 @@ int fd_columns(int fd) {
                 return -errno;
 
         if (ws.ws_col <= 0)
-                return -EIO;
+                return -ENODATA; /* some tty types come up with invalid row/column initially, return a recognizable error for that */
 
         return ws.ws_col;
 }
@@ -892,7 +892,7 @@ int fd_lines(int fd) {
                 return -errno;
 
         if (ws.ws_row <= 0)
-                return -EIO;
+                return -ENODATA; /* some tty types come up with invalid row/column initially, return a recognizable error for that */
 
         return ws.ws_row;
 }