From owner-svn-src-head@freebsd.org Sun May 7 18:01:51 2017 Return-Path: Delivered-To: svn-src-head@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 94577D62ACB; Sun, 7 May 2017 18:01:51 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B70EF1372; Sun, 7 May 2017 18:01:50 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v47I1iDL041344 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 7 May 2017 21:01:44 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v47I1iDL041344 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v47I1hc9041343; Sun, 7 May 2017 21:01:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 7 May 2017 21:01:43 +0300 From: Konstantin Belousov To: Edward Tomasz Napierala Cc: 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: <20170507180143.GA1622@kib.kiev.ua> References: <201705071721.v47HLNWB049018@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201705071721.v47HLNWB049018@repo.freebsd.org> User-Agent: Mutt/1.8.2 (2017-04-18) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 May 2017 18:01:51 -0000 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); > + if (error != 0) > + warn("ioctl"); > + > if (write(fd, query, sizeof(query)) != sizeof(query)) { > error = 1; > goto out;