summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-04-19 21:30:07 -0400
committerJakob Kaivo <jkk@ung.org>2022-04-19 21:30:07 -0400
commit9e60415967b7cb074c26d204bdc908a1962b60d8 (patch)
tree92b7ce894ef2597fd61f57e1ce2b2f3d9372b2bc
parent0045947d477b3ebc1d35a6711cc0853683dfb46f (diff)
attempt to open stderr for reading first to comply with POSIX
-rw-r--r--more.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/more.c b/more.c
index 8dcea05..800f0da 100644
--- a/more.c
+++ b/more.c
@@ -751,15 +751,16 @@ int main(int argc, char *argv[])
return ret;
}
- if (isatty(STDIN_FILENO)) {
- initscr();
- } else {
+ if (newterm(NULL, stdout, stderr) == NULL) {
FILE *tty = fopen("/dev/tty", "r");
if (tty == NULL) {
perror("more: couldn't open terminal");
return 1;
}
- newterm(NULL, stdout, tty);
+ if (newterm(NULL, stdout, tty) == NULL) {
+ perror("more: couldn't open terminal");
+ return 1;
+ }
}
cbreak();