|
cvsdist |
92bd44 |
--- zsh-4.0.4/Src/builtin.c.open Tue Oct 16 02:49:17 2001
|
|
cvsdist |
92bd44 |
+++ zsh-4.0.4/Src/builtin.c Wed May 15 11:55:32 2002
|
|
cvsdist |
92bd44 |
@@ -3489,7 +3489,7 @@ bin_read(char *name, char **args, char *
|
|
cvsdist |
92bd44 |
if (!zleactive) {
|
|
cvsdist |
92bd44 |
if (SHTTY == -1) {
|
|
cvsdist |
92bd44 |
/* need to open /dev/tty specially */
|
|
cvsdist |
92bd44 |
- if ((SHTTY = open("/dev/tty", O_RDWR|O_NOCTTY)) != -1) {
|
|
cvsdist |
92bd44 |
+ if ((SHTTY = block_open("/dev/tty", O_RDWR|O_NOCTTY)) != -1) {
|
|
cvsdist |
92bd44 |
haso = 1;
|
|
cvsdist |
92bd44 |
oshout = shout;
|
|
cvsdist |
92bd44 |
init_shout();
|
|
cvsdist |
92bd44 |
--- zsh-4.0.4/Src/init.c.open Wed Oct 24 04:16:32 2001
|
|
cvsdist |
92bd44 |
+++ zsh-4.0.4/Src/init.c Wed May 15 12:00:07 2002
|
|
cvsdist |
92bd44 |
@@ -397,7 +397,7 @@ init_io(void)
|
|
cvsdist |
92bd44 |
if (isatty(0)) {
|
|
cvsdist |
92bd44 |
zsfree(ttystrname);
|
|
cvsdist |
92bd44 |
if ((ttystrname = ztrdup(ttyname(0)))) {
|
|
cvsdist |
92bd44 |
- SHTTY = movefd(open(ttystrname, O_RDWR | O_NOCTTY));
|
|
cvsdist |
92bd44 |
+ SHTTY = movefd(block_open(ttystrname, O_RDWR | O_NOCTTY));
|
|
cvsdist |
92bd44 |
#ifdef TIOCNXCL
|
|
cvsdist |
92bd44 |
/*
|
|
cvsdist |
92bd44 |
* See if the terminal claims to be busy. If so, and fd 0
|
|
cvsdist |
92bd44 |
@@ -438,7 +438,7 @@ init_io(void)
|
|
cvsdist |
92bd44 |
ttystrname = ztrdup(ttyname(1));
|
|
cvsdist |
92bd44 |
}
|
|
cvsdist |
92bd44 |
if (SHTTY == -1 &&
|
|
cvsdist |
92bd44 |
- (SHTTY = movefd(open("/dev/tty", O_RDWR | O_NOCTTY))) != -1) {
|
|
cvsdist |
92bd44 |
+ (SHTTY = movefd(block_open("/dev/tty", O_RDWR | O_NOCTTY))) != -1) {
|
|
cvsdist |
92bd44 |
zsfree(ttystrname);
|
|
cvsdist |
92bd44 |
ttystrname = ztrdup(ttyname(SHTTY));
|
|
cvsdist |
92bd44 |
}
|
|
cvsdist |
92bd44 |
@@ -1235,3 +1235,33 @@ zsh_main(int argc, char **argv)
|
|
cvsdist |
92bd44 |
: "use 'logout' to logout.", NULL, 0);
|
|
cvsdist |
92bd44 |
}
|
|
cvsdist |
92bd44 |
}
|
|
cvsdist |
92bd44 |
+
|
|
cvsdist |
92bd44 |
+/**/
|
|
cvsdist |
92bd44 |
+int
|
|
cvsdist |
92bd44 |
+block_open (const char *tty, int flags)
|
|
cvsdist |
92bd44 |
+{
|
|
cvsdist |
92bd44 |
+ int saved_errno;
|
|
cvsdist |
92bd44 |
+ int fd;
|
|
cvsdist |
92bd44 |
+
|
|
cvsdist |
92bd44 |
+ if ((flags & O_NONBLOCK) == 0) {
|
|
cvsdist |
92bd44 |
+ fd = open (tty, flags | O_NONBLOCK);
|
|
cvsdist |
92bd44 |
+ if (fd == -1)
|
|
cvsdist |
92bd44 |
+ return fd;
|
|
cvsdist |
92bd44 |
+ flags = fcntl(fd, F_GETFL);
|
|
cvsdist |
92bd44 |
+ if (flags == -1)
|
|
cvsdist |
92bd44 |
+ goto bad;
|
|
cvsdist |
92bd44 |
+ flags &= ~O_NONBLOCK;
|
|
cvsdist |
92bd44 |
+ if (fcntl(fd, F_SETFL, flags) == -1)
|
|
cvsdist |
92bd44 |
+ goto bad;
|
|
cvsdist |
92bd44 |
+ }
|
|
cvsdist |
92bd44 |
+ else
|
|
cvsdist |
92bd44 |
+ fd = open (tty, flags);
|
|
cvsdist |
92bd44 |
+
|
|
cvsdist |
92bd44 |
+ return fd;
|
|
cvsdist |
92bd44 |
+
|
|
cvsdist |
92bd44 |
+bad:
|
|
cvsdist |
92bd44 |
+ saved_errno = errno;
|
|
cvsdist |
92bd44 |
+ close (fd);
|
|
cvsdist |
92bd44 |
+ errno = saved_errno;
|
|
cvsdist |
92bd44 |
+ return -1;
|
|
cvsdist |
92bd44 |
+}
|