Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 May 2017 21:01:43 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Edward Tomasz Napierala <trasz@FreeBSD.org>
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>
In-Reply-To: <201705071721.v47HLNWB049018@repo.freebsd.org>
References:  <201705071721.v47HLNWB049018@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <darius@dons.net.au>
>   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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170507180143.GA1622>