zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: zpty -t
@ 2001-02-13 13:13 Sven Wischnowsky
  2001-02-13 14:11 ` Andrej Borsenkow
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Wischnowsky @ 2001-02-13 13:13 UTC (permalink / raw)
  To: zsh-workers


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@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-02-13 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-13 13:13 PATCH: zpty -t Sven Wischnowsky
2001-02-13 14:11 ` Andrej Borsenkow
2001-02-13 14:17   ` Andrej Borsenkow

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).