Date: Tue, 23 May 2017 08:04:36 +0000 (UTC) From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r318726 - stable/11/usr.bin/resizewin Message-ID: <201705230804.v4N84a2Y095112@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trasz Date: Tue May 23 08:04:36 2017 New Revision: 318726 URL: https://svnweb.freebsd.org/changeset/base/318726 Log: MFC r317909: 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. Modified: stable/11/usr.bin/resizewin/resizewin.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/resizewin/resizewin.c ============================================================================== --- stable/11/usr.bin/resizewin/resizewin.c Tue May 23 08:02:21 2017 (r318725) +++ stable/11/usr.bin/resizewin/resizewin.c Tue May 23 08:04:36 2017 (r318726) @@ -52,7 +52,7 @@ main(__unused int argc, __unused char ** { 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 ** 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705230804.v4N84a2Y095112>