From 8325662186ace9d9d356f6ab37433df98b4842da Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 8 Feb 2020 15:50:00 +0100 Subject: [PATCH] more: Read keystrokes from stdout instead of trying to re-open it If we're running more on a TTY that we don't have filesystem access to, we can't rely on open(ttyname(STDOUT_FILENO)). Since all the stdio fd's are opened read/write anyway, we can just read from stdout, even if it feels a bit weird. :^) --- Userland/more.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Userland/more.cpp b/Userland/more.cpp index e50e7fa186..2299438aa3 100644 --- a/Userland/more.cpp +++ b/Userland/more.cpp @@ -50,11 +50,7 @@ int main(int argc, char** argv) return 1; } - key_fd = open(ttyname(1), O_RDONLY); - if (key_fd < 0) { - perror("open"); - return 1; - } + key_fd = STDOUT_FILENO; struct winsize ws; ioctl(1, TIOCGWINSZ, &ws);