From c9491a4b97d2d85d9b9733acb87f72f5b6d62dc8 Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Tue, 31 Jan 2006 18:58:44 +0000 Subject: 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 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 -- cgit v0.10.2