public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] Cygwin: pty: Prevent meaningless ResizePseudoConsole() calls.
@ 2020-05-28 13:49 Takashi Yano
  2020-05-28 14:45 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Takashi Yano @ 2020-05-28 13:49 UTC (permalink / raw)
  To: cygwin-patches

- This patch prevents to call ResizePseudoConsole() unless the pty
  is resized.
---
 winsup/cygwin/fhandler_tty.cc | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index f29a2c214..b091765b3 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -2615,18 +2615,18 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg)
       *(struct winsize *) arg = get_ttyp ()->winsize;
       break;
     case TIOCSWINSZ:
-      /* FIXME: Pseudo console can be accessed via its handle
-	 only in the process which created it. What else can we do? */
-      if (get_pseudo_console () && get_ttyp ()->master_pid == myself->pid)
-	{
-	  COORD size;
-	  size.X = ((struct winsize *) arg)->ws_col;
-	  size.Y = ((struct winsize *) arg)->ws_row;
-	  ResizePseudoConsole (get_pseudo_console (), size);
-	}
       if (get_ttyp ()->winsize.ws_row != ((struct winsize *) arg)->ws_row
 	  || get_ttyp ()->winsize.ws_col != ((struct winsize *) arg)->ws_col)
 	{
+	  /* FIXME: Pseudo console can be accessed via its handle
+	     only in the process which created it. What else can we do? */
+	  if (get_pseudo_console () && get_ttyp ()->master_pid == myself->pid)
+	    {
+	      COORD size;
+	      size.X = ((struct winsize *) arg)->ws_col;
+	      size.Y = ((struct winsize *) arg)->ws_row;
+	      ResizePseudoConsole (get_pseudo_console (), size);
+	    }
 	  get_ttyp ()->winsize = *(struct winsize *) arg;
 	  get_ttyp ()->kill_pgrp (SIGWINCH);
 	}
-- 
2.26.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Cygwin: pty: Prevent meaningless ResizePseudoConsole() calls.
  2020-05-28 13:49 [PATCH] Cygwin: pty: Prevent meaningless ResizePseudoConsole() calls Takashi Yano
@ 2020-05-28 14:45 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2020-05-28 14:45 UTC (permalink / raw)
  To: cygwin-patches

On May 28 22:49, Takashi Yano via Cygwin-patches wrote:
> - This patch prevents to call ResizePseudoConsole() unless the pty
>   is resized.
> ---
>  winsup/cygwin/fhandler_tty.cc | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
> index f29a2c214..b091765b3 100644
> --- a/winsup/cygwin/fhandler_tty.cc
> +++ b/winsup/cygwin/fhandler_tty.cc
> @@ -2615,18 +2615,18 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg)
>        *(struct winsize *) arg = get_ttyp ()->winsize;
>        break;
>      case TIOCSWINSZ:
> -      /* FIXME: Pseudo console can be accessed via its handle
> -	 only in the process which created it. What else can we do? */
> -      if (get_pseudo_console () && get_ttyp ()->master_pid == myself->pid)
> -	{
> -	  COORD size;
> -	  size.X = ((struct winsize *) arg)->ws_col;
> -	  size.Y = ((struct winsize *) arg)->ws_row;
> -	  ResizePseudoConsole (get_pseudo_console (), size);
> -	}
>        if (get_ttyp ()->winsize.ws_row != ((struct winsize *) arg)->ws_row
>  	  || get_ttyp ()->winsize.ws_col != ((struct winsize *) arg)->ws_col)
>  	{
> +	  /* FIXME: Pseudo console can be accessed via its handle
> +	     only in the process which created it. What else can we do? */
> +	  if (get_pseudo_console () && get_ttyp ()->master_pid == myself->pid)
> +	    {
> +	      COORD size;
> +	      size.X = ((struct winsize *) arg)->ws_col;
> +	      size.Y = ((struct winsize *) arg)->ws_row;
> +	      ResizePseudoConsole (get_pseudo_console (), size);
> +	    }
>  	  get_ttyp ()->winsize = *(struct winsize *) arg;
>  	  get_ttyp ()->kill_pgrp (SIGWINCH);
>  	}
> -- 
> 2.26.2

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-28 14:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 13:49 [PATCH] Cygwin: pty: Prevent meaningless ResizePseudoConsole() calls Takashi Yano
2020-05-28 14:45 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).