From 0ea4198f0a9ef4aa2226b437bfa6e9a741ea99b0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 Jul 2024 17:45:26 +0200 Subject: [PATCH] terminal-util: add recognizable error if cols/rows of tty are initially not initialized 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index df091c36a96..c2ff3ca85a8 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -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; } -- 2.47.3