diff --git a/man/remind.1.in b/man/remind.1.in index 6bfcf635..dcf17d93 100644 --- a/man/remind.1.in +++ b/man/remind.1.in @@ -3848,9 +3848,10 @@ integer. .TP .B columns([s_arg]) If called with no arguments, \fBcolumns()\fR behaves as follows: -If standard output is a TTY, returns the width of the terminal in columns. -If standard output is not a TTY, attempts to open "/dev/tty" to obtain -the terminal size. If this fails, returns -1. +If either standard output or standard error is a TTY, returns the +width of the terminal in columns. If neither standard output nor +standard error is a TTY, attempts to open "/dev/tty" to obtain the +terminal size. If this fails, returns -1. .RS .PP If called with a single string argument, \fBcolumns(str)\fR returns @@ -4638,9 +4639,10 @@ Returns the date as provided by the operating system. This is in contrast to in calendar mode, or if a date has been supplied on the command line. .TP .B rows() -If standard output is a TTY, returns the height of the terminal in rows. -If standard output is not a TTY, attempts to open "/dev/tty" to obtain -the terminal size. If this fails, returns -1. +If either standard output or standard error is a TTY, returns the +height of the terminal in rows. If neither standard output nor +standard error is a TTY, attempts to open "/dev/tty" to obtain the +terminal size. If this fails, returns -1. .TP .B sgn(i_num) Returns \-1 if \fInum\fR is negative, 1 if \fInum\fR is positive, diff --git a/src/funcs.c b/src/funcs.c index 2732c93f..1c8ad717 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -4889,10 +4889,13 @@ rows_or_cols(func_info *info, int want_rows) { struct winsize w; int fd = STDOUT_FILENO; - int opened = 0; RetVal.type = INT_TYPE; + if (!isatty(fd)) { + /* Try STDERR fd if STDOUT fd is not a tty */ + fd = STDERR_FILENO; + } if (!isatty(fd)) { fd = open("/dev/tty", O_RDONLY); if (fd < 0) {