aboutsummaryrefslogtreecommitdiffstats
path: root/tty.c
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2006-01-31 18:58:44 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2006-01-31 18:58:44 (GMT)
commitc9491a4b97d2d85d9b9733acb87f72f5b6d62dc8 (patch)
tree763763488ddcd81c912d1dc81ae9a1a8026720b6 /tty.c
parentdeb5745614e04b339d8bd5fce29ce9da7109e722 (diff)
downloadpowwow-c9491a4b97d2d85d9b9733acb87f72f5b6d62dc8.zip
powwow-c9491a4b97d2d85d9b9733acb87f72f5b6d62dc8.tar.gz
powwow-c9491a4b97d2d85d9b9733acb87f72f5b6d62dc8.tar.bz2
A patch that fixes a problem with not restoring the fcntl
flags for stdout before running a #! command. To trigger the bug in 1.2.9, just type "#! cat" and cat will die with EAGAIN. Patch by Dain
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tty.c b/tty.c
index 7053407..f9b28e7 100644
--- a/tty.c
+++ b/tty.c
@@ -144,6 +144,7 @@ static int wrapglitch = 0;
#ifdef USE_LOCALE
FILE *tty_read_stream, *tty_write_stream;
+static int orig_read_fd_fl;
#endif
#ifdef USE_SGTTY
@@ -190,6 +191,11 @@ void tty_start __P0 (void)
ioctl(tty_read_fd, TCSETS, &ttyb);
#endif /* USE_SGTTY */
+#ifdef USE_LOCALE
+ orig_read_fd_fl = fcntl(tty_read_fd, F_GETFL);
+ fcntl(tty_read_fd, F_SETFL, O_NONBLOCK | orig_read_fd_fl);
+#endif
+
tty_puts(kpadstart);
tty_flush();
@@ -214,6 +220,9 @@ void tty_quit __P0 (void)
#endif /* USE_SGTTY */
tty_puts(kpadend);
tty_flush();
+#ifdef USE_LOCALE
+ fcntl(tty_read_fd, F_SETFL, orig_read_fd_fl);
+#endif
}
/*
@@ -304,7 +313,6 @@ void tty_bootstrap __P0 (void)
#ifdef USE_LOCALE
tty_read_stream = stdin;
tty_write_stream = stdout;
- fcntl(tty_read_fd, F_SETFL, O_NONBLOCK | fcntl(tty_read_fd, F_GETFL));
#endif
#ifndef USE_VT100