Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: zpty -t
- X-seq: zsh-workers 13462
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: zpty -t
- Date: Tue, 13 Feb 2001 14:13:40 +0100 (MET)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
I found a report about zpty -t not working properly on the debian bug
list. For example:
% zpty z zsh
% zpty -w z exit
% zpty -r z
% zpty -t z && echo running
printed `running'.
Below is my n+1'th attempt at making this better, not relying on
read_poll() in checkptycmd() (because that uses select() which
succeeds even if the process has terminated and there isn't really
anything to read).
Dunno if this is really any better, but at least it solves the problem
above. What do the Cygwin folks say?
Bye
Sven
Index: Src/Modules/zpty.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/zpty.c,v
retrieving revision 1.21
diff -u -r1.21 zpty.c
--- Src/Modules/zpty.c 2001/01/16 13:44:20 1.21
+++ Src/Modules/zpty.c 2001/02/13 13:12:00
@@ -430,13 +430,19 @@
static void
checkptycmd(Ptycmd cmd)
{
- if (cmd->read != -1)
+ char c;
+ int r;
+
+ if (cmd->read != -1 || cmd->fin)
return;
- if (!read_poll(cmd->fd, &cmd->read, 0) &&
- kill(cmd->pid, 0) < 0) {
- cmd->fin = 1;
- zclose(cmd->fd);
+ 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;
}
static int
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author