From 9e60415967b7cb074c26d204bdc908a1962b60d8 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 19 Apr 2022 21:30:07 -0400 Subject: attempt to open stderr for reading first to comply with POSIX --- more.c | 9 +++++---- 1 file 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(); -- cgit v1.2.1