summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/util/ttysize.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/util/ttysize.c b/lib/util/ttysize.c
index 221ea92b5..c14e3a85d 100644
--- a/lib/util/ttysize.c
+++ b/lib/util/ttysize.c
@@ -39,11 +39,12 @@ get_ttysize_ioctl(int *rowp, int *colp)
struct winsize wsize;
debug_decl(get_ttysize_ioctl, SUDO_DEBUG_UTIL);
- if (ioctl(STDERR_FILENO, TIOCGWINSZ, &wsize) == 0 &&
- wsize.ws_row != 0 && wsize.ws_col != 0) {
- *rowp = wsize.ws_row;
- *colp = wsize.ws_col;
- debug_return_int(0);
+ if (isatty(STDERR_FILENO) && ioctl(STDERR_FILENO, TIOCGWINSZ, &wsize) == 0) {
+ if (wsize.ws_row != 0 && wsize.ws_col != 0) {
+ *rowp = wsize.ws_row;
+ *colp = wsize.ws_col;
+ debug_return_int(0);
+ }
}
debug_return_int(-1);
}