aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-11-26 17:19:04 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-11-26 17:19:04 +0100
commitf42a3165e8b527a81865870f74865c1cd99b7196 (patch)
tree5ee1d82bb3e1a42d678f8559bfc4d3061e7e3f2f
parentab65ab5d027e97ead372264a6ecfd3ac642299ba (diff)
downloadvis-f42a3165e8b527a81865870f74865c1cd99b7196.tar.gz
vis-f42a3165e8b527a81865870f74865c1cd99b7196.tar.xz
vis: re-open /dev/tty read-writeable
libtermkey's initialization routine tries to write to the underlying file descriptor which fails with EBADF if it is opened read only. This was a problem in the terminal restore code called after a shell command is executed. It should fix the following: $ echo foo | vis - > bar :!/bin/sh exit where before vis would no longer accept any input.
-rw-r--r--main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/main.c b/main.c
index 1b6f14d..7bab3cd 100644
--- a/main.c
+++ b/main.c
@@ -2280,7 +2280,7 @@ int main(int argc, char *argv[]) {
if (len == -1)
vis_die(vis, "Can not read from stdin\n");
text_snapshot(txt);
- int fd = open("/dev/tty", O_RDONLY);
+ int fd = open("/dev/tty", O_RDWR);
if (fd == -1)
vis_die(vis, "Can not reopen stdin\n");
dup2(fd, STDIN_FILENO);