This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fhandler_tty patch


On Sun, Nov 03, 2002 at 06:57:42PM -0500, Sergey Okhapkin wrote:
>The patch resolves -1 return value from ioctl(slave_tty, TIOCSWINSZ, ...)
>problem and avoids extra SIGWINCH if the window size did not change.
>
>2002-11-03  Sergey Okhapkin  <sos@prospect.com.ru>
>
>	* fhandler_tty.cc (fhandler_tty_slave::ioctl): Do nothing if the new
>	window size is equal to the old one.  Send SIGWINCH if slave connected
>	to a pseudo tty.
>	(fhandler_pty_master::ioctl): Do nothing if the new window size is
>	equal to the old one.

Is this according to some standard?  It seems like we're sending too many
SIGWINCHes with your patch.

cgf

Index: fhandler_tty.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_tty.cc,v
retrieving revision 1.76
diff -u -p -r1.76 fhandler_tty.cc
--- fhandler_tty.cc	20 Oct 2002 04:15:50 -0000	1.76
+++ fhandler_tty.cc	3 Nov 2002 23:35:43 -0000
@@ -955,12 +955,23 @@ fhandler_tty_slave::ioctl (unsigned int 
       get_ttyp ()->winsize = get_ttyp ()->arg.winsize;
       break;
     case TIOCSWINSZ:
-      get_ttyp ()->ioctl_retval = -1;
-      get_ttyp ()->arg.winsize = * (struct winsize *) arg;
-      if (ioctl_request_event)
-	SetEvent (ioctl_request_event);
-      if (ioctl_done_event)
-	WaitForSingleObject (ioctl_done_event, INFINITE);
+      if (get_ttyp ()->winsize.ws_row != ((struct winsize *) arg)->ws_row
+	  || get_ttyp ()->winsize.ws_col != ((struct winsize *) arg)->ws_col)
+        {
+          get_ttyp ()->arg.winsize = * (struct winsize *) arg;
+          if (ioctl_request_event)
+	    {
+              get_ttyp ()->ioctl_retval = -1;
+	      SetEvent (ioctl_request_event);
+	    }
+	  else
+	    {
+	      get_ttyp ()->winsize = * (struct winsize *) arg;
+	      kill (-get_ttyp ()->getpgid (), SIGWINCH);
+	    }
+          if (ioctl_done_event)
+	    WaitForSingleObject (ioctl_done_event, INFINITE);
+	}
       break;
     }
 
@@ -1103,8 +1114,12 @@ fhandler_pty_master::ioctl (unsigned int
 	* (struct winsize *) arg = get_ttyp ()->winsize;
 	break;
       case TIOCSWINSZ:
-	get_ttyp ()->winsize = * (struct winsize *) arg;
-	kill (-get_ttyp ()->getpgid (), SIGWINCH);
+        if (get_ttyp ()->winsize.ws_row != ((struct winsize *) arg)->ws_row
+	    || get_ttyp ()->winsize.ws_col != ((struct winsize *) arg)->ws_col)
+          {
+	    get_ttyp ()->winsize = * (struct winsize *) arg;
+	    kill (-get_ttyp ()->getpgid (), SIGWINCH);
+	  }
 	break;
       case FIONBIO:
 	set_nonblocking (*(int *) arg);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]