From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: zpty -t
Date: Tue, 13 Feb 2001 14:13:40 +0100 (MET) [thread overview]
Message-ID: <200102131313.OAA13149@beta.informatik.hu-berlin.de> (raw)
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
next reply other threads:[~2001-02-13 13:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-02-13 13:13 Sven Wischnowsky [this message]
2001-02-13 14:11 ` Andrej Borsenkow
2001-02-13 14:17 ` 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=200102131313.OAA13149@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--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).