From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: Confirming X02zlevi test failures
Date: Thu, 27 Nov 2014 15:11:06 +0100 [thread overview]
Message-ID: <1339.1417097466@thecus.kiddle.eu> (raw)
In-Reply-To: <141126083746.ZM23932@torch.brasslantern.com>
Bart wrote:
> It shouldn't be hard to write a test case though it requires a person to
> drive it. Open /dev/tty, set icanon, sleep while the user enters some
> typeahead, set -icanon and then see if you can read the typeahead. Then
> try the icanon flop in the opposite order. It might even be possible to
> do it with a script and stty rather than a C program, although it might
> also require that all the frobbing and reading use the same (not a dup of
> the same) file descriptor.
I'd have thought simply checking that zsh doesn't lose typeahead would
be sufficient but since I already had a test program that was not far
from what you describe, I've modified and attached it. Is opening
/dev/tty instead of fd 0 necessary? You'll need to manually swap the
icanons. It's probably best to try to get an EOF in before the 3 seconds
have elapsed. Let me know if you see a problem on any system you use.
Oliver
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <termios.h>
void
gettyinfo(struct termios *ti)
{
if (tcgetattr(0, ti) == -1)
fprintf(stderr, "bad tcgets: %d", errno);
}
void
settyinfo(struct termios *ti)
{
while (tcsetattr(0, TCSADRAIN, ti) == -1 && errno == EINTR)
;
}
int main() {
struct termios ti;
char cptr[10];
ssize_t size;
gettyinfo(&ti);
ti.c_lflag &= ~ICANON;
settyinfo(&ti);
sleep(3);
ti.c_lflag |= ICANON;
settyinfo(&ti);
size = read(0, cptr, 9);
if (size > 0) {
cptr[size] = '\0';
printf("\nGot: %s\n", cptr);
}
}
next prev parent reply other threads:[~2014-11-27 14:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-19 16:50 Bart Schaefer
2014-11-19 17:25 ` Ray Andrews
2014-11-19 23:05 ` Oliver Kiddle
2014-11-20 6:20 ` Bart Schaefer
2014-11-20 15:42 ` Jun T.
2014-11-20 17:18 ` Bart Schaefer
2014-11-21 14:37 ` Oliver Kiddle
2014-11-21 18:18 ` Jun T.
2014-11-21 18:56 ` Bart Schaefer
2014-11-23 1:37 ` Jun T.
2014-11-23 3:32 ` Bart Schaefer
2014-11-23 7:44 ` Jun T.
2014-11-24 0:11 ` Bart Schaefer
2014-11-23 9:00 ` Oliver Kiddle
2014-11-23 18:37 ` Bart Schaefer
2014-11-25 17:13 ` Jun T.
2014-11-25 17:32 ` Jun T.
2014-11-25 19:01 ` Bart Schaefer
2014-11-26 2:31 ` Jun T.
2014-11-26 14:51 ` Oliver Kiddle
2014-11-26 15:45 ` Peter Stephenson
2014-11-26 16:37 ` Bart Schaefer
2014-11-27 14:11 ` Oliver Kiddle [this message]
2014-12-01 10:58 ` Jun T.
2014-12-05 14:36 ` Oliver Kiddle
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=1339.1417097466@thecus.kiddle.eu \
--to=okiddle@yahoo.co.uk \
--cc=zsh-workers@zsh.org \
/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).