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