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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user