Skip to content

Commit

Permalink
more: Read keystrokes from stdout instead of trying to re-open it
Browse files Browse the repository at this point in the history
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. :^)
  • Loading branch information
awesomekling committed Feb 8, 2020
1 parent 1037a1d commit 8325662
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions Userland/more.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8325662

Please sign in to comment.