From owner-svn-src-all@freebsd.org Sun May 7 18:28:13 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CC933D62310; Sun, 7 May 2017 18:28:13 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mailout.stack.nl (mailout05.stack.nl [IPv6:2001:610:1108:5010::202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mailout.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 3F6579BD; Sun, 7 May 2017 18:28:13 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mailout.stack.nl (Postfix) with ESMTP id B1C3C63; Sun, 7 May 2017 20:28:02 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 9C55E28497; Sun, 7 May 2017 20:28:02 +0200 (CEST) Date: Sun, 7 May 2017 20:28:02 +0200 From: Jilles Tjoelker To: Konstantin Belousov Cc: Edward Tomasz Napierala , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r317909 - head/usr.bin/resizewin Message-ID: <20170507182802.GA5248@stack.nl> References: <201705071721.v47HLNWB049018@repo.freebsd.org> <20170507180143.GA1622@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170507180143.GA1622@kib.kiev.ua> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 May 2017 18:28:14 -0000 On Sun, May 07, 2017 at 09:01:43PM +0300, Konstantin Belousov wrote: > On Sun, May 07, 2017 at 05:21:23PM +0000, Edward Tomasz Napierala wrote: > > Author: trasz > > Date: Sun May 7 17:21:22 2017 > > New Revision: 317909 > > URL: https://svnweb.freebsd.org/changeset/base/317909 > > Log: > > 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 > > MFC after: 2 weeks > > Sponsored by: DARPA, AFRL > > Differential Revision: https://reviews.freebsd.org/D10624 > > Modified: > > head/usr.bin/resizewin/resizewin.c > > > > Modified: head/usr.bin/resizewin/resizewin.c > > ============================================================================== > > --- head/usr.bin/resizewin/resizewin.c Sun May 7 14:59:45 2017 (r317908) > > +++ head/usr.bin/resizewin/resizewin.c Sun May 7 17:21:22 2017 (r317909) > > @@ -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); > This is correctly spelled tcflush(fd, TCIOFLUSH); Alternatively, the above TCSANOW could be changed to TCSAFLUSH. The effect is slightly different in that pending output is drained instead of discarded. In any case, the TIOCFLUSH ioctl is non-standard and should not be used directly. -- Jilles Tjoelker