Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: accessing zpty after child has finished (Mac OS X)
On Dec 17, 1:33am, Jun T. wrote:
}
} - if ((r = read(cmd->fd, &c, 1)) < 0) {
} + if ((r = read(cmd->fd, &c, 1)) <= 0) {
I don't see any significant ill effect from this other than some extra
kill(pid, 0) calls which should be low overhead.
There is a chance that it will leave some child output un-consumed on
platforms where the PTY does maintain the buffer until both ends are
closed. There's no generalized way around this except for using the
same kind of special sync write/read that's exchanged when the PTY is
being set up, but that would have to be done out of band, whereas the
startup sync is in-band (uses the PTY itself).
However, Jun's change makes a subsequent test unnecessary. I propose
this instead:
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c
index fca0cc1..d119658 100644
--- a/Src/Modules/zpty.c
+++ b/Src/Modules/zpty.c
@@ -510,14 +510,14 @@ checkptycmd(Ptycmd cmd)
if (cmd->read != -1 || cmd->fin)
return;
- if ((r = read(cmd->fd, &c, 1)) < 0) {
+ if ((r = read(cmd->fd, &c, 1)) <= 0) {
if (kill(cmd->pid, 0) < 0) {
cmd->fin = 1;
zclose(cmd->fd);
}
return;
}
- if (r) cmd->read = (int) c;
+ cmd->read = (int) c;
}
static int
Messages sorted by:
Reverse Date,
Date,
Thread,
Author