diff options
author | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2017-05-07 17:21:22 +0000 |
---|---|---|
committer | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2017-05-07 17:21:22 +0000 |
commit | 7ffc8a54188f155dea60f56b91668574a4eead18 (patch) | |
tree | 06a72f91466390f21c0069b7503468ab510087bf /usr.bin/resizewin | |
parent | 215b29f62c7481f7d812384610ea200174b0e250 (diff) | |
download | src-test-7ffc8a54188f155dea60f56b91668574a4eead18.tar.gz src-test-7ffc8a54188f155dea60f56b91668574a4eead18.zip |
Make resizewin(1) discard the terminal queues, to lower the chance
for "unable to parse response" error which happens when youre typing
too fast for the machine you're running it on.
Reviewed by: cem, Daniel O'Connor <darius@dons.net.au>
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D10624
Notes
Notes:
svn path=/head/; revision=317909
Diffstat (limited to 'usr.bin/resizewin')
-rw-r--r-- | usr.bin/resizewin/resizewin.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/resizewin/resizewin.c b/usr.bin/resizewin/resizewin.c index 89a2b1bc63746..6ab2778caaa4b 100644 --- a/usr.bin/resizewin/resizewin.c +++ b/usr.bin/resizewin/resizewin.c @@ -52,7 +52,7 @@ main(__unused int argc, __unused char **argv) { struct termios old, new; struct winsize w; - int ret, fd, cnt, error; + int ret, fd, cnt, error, what; char data[20]; struct timeval then, now; @@ -71,6 +71,12 @@ main(__unused int argc, __unused char **argv) if (tcsetattr(fd, TCSANOW, &new) == -1) exit(1); + /* Discard input received so far */ + what = FREAD | FWRITE; + error = ioctl(fd, TIOCFLUSH, &what); + if (error != 0) + warn("ioctl"); + if (write(fd, query, sizeof(query)) != sizeof(query)) { error = 1; goto out; |