zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: read_poll Re: PATCH: Zpty cleanup (merge 13061 with 13116)
Date: Wed, 8 Nov 2000 15:58:13 +0000	[thread overview]
Message-ID: <1001108155814.ZM14060@candle.brasslantern.com> (raw)
In-Reply-To: <200011081020.LAA20686@beta.informatik.hu-berlin.de>
In-Reply-To: <001a01c04970$948d58f0$21c9ca95@mow.siemens.ru>
In-Reply-To: <001c01c0498c$a152ef70$21c9ca95@mow.siemens.ru>
In-Reply-To: <000101c04992$a0657370$21c9ca95@mow.siemens.ru>

On Nov 8, 11:20am, Sven Wischnowsky wrote:
}
} Bart Schaefer wrote:
} 
} > However, that does not mean that the rest of the tests should be skipped
} > when select() returns 0.  A return of 0 means the select() timed out,
} > which (apparently) might happen under Cygwin even if there actually are
} > characters available to be read.  Peter/Andrej, is that the case?
} 
} I don't know about Cygwin, but that blocking read (line 1381) is
} exactly the test I wanted to avoid.

The read on line 1381 is *non-*blocking.  Since polltty is now always zero
when called from zpty, the setblock_fd() call is made before the read() is
attempted.  That was the patch I first committed which started me down the
road of merging in your changes.

On Nov 8,  1:42pm, Andrej Borsenkow wrote:
} Subject: RE: PATCH: Zpty cleanup (merge 13061 with 13116)
}
} I had not much time recently. Casual test shows, that zpty is currently
} completely broken on current Cygwin (1.1.5-4 as of this writing); I do not
} claim that it is zsh problem, but recent changes may have made it worse.

More on this in the other zpty thread ...

} About select - so far there seems to be no known problems under cygwin
} (that does not mean, there are no problems).

OK, if there are no known problems with select, then the test on line
1376 can change from `ret <= 0' to `ret < 0' -- and in that case it's
possible that we could split read_poll() into two cases, HAVE_SELECT v.
all the other code that's there.  I won't do that for now, though.

This still doesn't address my complaint that select() on my linux box
returns "ready for reading" when in fact the result of read() will be
an I/O error.  That makes no difference to `read -t' (for which the
read_poll() code was originally written) but it screws up the return
value of `zpty -r'.

On Nov 8,  5:03pm, Andrej Borsenkow wrote:
} Subject: read_poll RE: PATCH: Zpty cleanup (merge 13061 with 13116)
}
} read_poll tries to read from fd and stores the character it has read in
} readchar; that is cmd->read when called from checkptycmd. But this value does
} not seem to be used anywhere in read loop that looks like read_poll simply
} eats up this readahead char ...

You're correct.  The code Sven referenced at line 474 needs to be repeated
after line 484.

Index: Src/utils.c
===================================================================
@@ -1373,7 +1373,7 @@
 #endif
 #endif
 
-    if (ret <= 0) {
+    if (ret < 0) {
 	/*
 	 * Final attempt: set non-blocking read and try to read a character.
 	 * Praise Bill, this works under Cygwin (nothing else seems to).
Index: Src/Modules/zpty.c
===================================================================
@@ -482,6 +482,11 @@
 	    checkptycmd(cmd);
 	    if (cmd->fin)
 		break;
+	    if (cmd->read != -1) {
+		buf[++used] = (char) cmd->read;
+		seen = 1;
+		cmd->read = -1;
+	    }
 	}
 	if ((ret = read(cmd->fd, buf + used, 1)) == 1) {
 	    seen = 1;


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


  reply	other threads:[~2000-11-08 15:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-08 14:09 read_poll " Sven Wischnowsky
2000-11-08 14:46 ` Andrej Borsenkow
2000-11-08 15:58   ` Bart Schaefer [this message]
2000-11-08 17:00     ` PATCH: read_poll " Bart Schaefer
2000-11-08 19:10     ` Bug in cygwin with select and master pty Andrej Borsenkow
  -- strict thread matches above, loose matches on Subject: below --
2000-11-09  8:12 PATCH: read_poll Re: PATCH: Zpty cleanup (merge 13061 with 13116) Sven Wischnowsky
2000-11-09  8:09 Sven Wischnowsky
2000-11-08 10:20 Sven Wischnowsky
2000-11-08 10:42 ` Andrej Borsenkow
2000-11-04 23:29 PATCH: Misc. zpty tweaks, plus commentary Bart Schaefer
2000-11-05  1:59 ` Bart Schaefer
2000-11-05  4:35 ` Bart Schaefer
2000-11-05  9:12   ` PATCH: Zpty cleanup (merge 13061 with 13116) Bart Schaefer
2000-11-08 14:03     ` read_poll " Andrej Borsenkow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1001108155814.ZM14060@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).