mirror of
				https://github.com/mintty/wsltty.git
				synced 2025-11-04 00:51:52 +00:00 
			
		
		
		
	Compare commits
	
		
			10 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					9469b2b5f5 | ||
| 
						 | 
					5b27a3d3c8 | ||
| 
						 | 
					ab46c2b1b0 | ||
| 
						 | 
					2e56730282 | ||
| 
						 | 
					d67ce45c3e | ||
| 
						 | 
					6e74ab4d5b | ||
| 
						 | 
					ee4e403f4c | ||
| 
						 | 
					a332cf8eaa | ||
| 
						 | 
					07aa6c692d | ||
| 
						 | 
					74dad091ce | 
@@ -1,36 +1,16 @@
 | 
			
		||||
Date: Tue, 15 Sep 2020 06:15:34 +0200
 | 
			
		||||
Subject: [PATCH] notify window size change via escaped inband information
 | 
			
		||||
 (Biswa96/wslbridge2#21, mintty/wsltty#220)
 | 
			
		||||
Co-authored-by: Thomas Wolff <towo@towo.net>
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 src/wslbridge2-backend.cpp | 87 +++++++++++++++++++++++++++++++++++++-
 | 
			
		||||
 src/wslbridge2.cpp         | 83 ++++++++++++++++++++++++++++++------
 | 
			
		||||
 2 files changed, 155 insertions(+), 15 deletions(-)
 | 
			
		||||
 | 
			
		||||
diff --git a/src/wslbridge2-backend.cpp b/src/wslbridge2-backend.cpp
 | 
			
		||||
index b50ee9c..ad429ae 100644
 | 
			
		||||
index 8b86cc6..63a19e5 100644
 | 
			
		||||
--- a/src/wslbridge2-backend.cpp
 | 
			
		||||
+++ b/src/wslbridge2-backend.cpp
 | 
			
		||||
@@ -24,6 +24,7 @@
 | 
			
		||||
 #include <termios.h>
 | 
			
		||||
@@ -17,6 +17,7 @@
 | 
			
		||||
 #include <sys/wait.h>
 | 
			
		||||
 #include <unistd.h>
 | 
			
		||||
 #include <wordexp.h>
 | 
			
		||||
+#include <limits.h> // PIPE_BUF
 | 
			
		||||
 
 | 
			
		||||
 #include <string>
 | 
			
		||||
 #include <vector>
 | 
			
		||||
@@ -315,6 +316,9 @@ int main(int argc, char *argv[])
 | 
			
		||||
         /* Use dupped master fd to read OR write */
 | 
			
		||||
         const int mfd_dp = dup(mfd);
 | 
			
		||||
         assert(mfd_dp > 0);
 | 
			
		||||
+#ifdef debug_to_input
 | 
			
		||||
+        FILE * debug = fdopen(mfd_dp, "w"); // for fprintf
 | 
			
		||||
+#endif
 | 
			
		||||
 
 | 
			
		||||
         sigset_t set;
 | 
			
		||||
         sigemptyset(&set);
 | 
			
		||||
@@ -333,6 +337,7 @@ int main(int argc, char *argv[])
 | 
			
		||||
@@ -196,6 +197,7 @@ int main(int argc, char *argv[])
 | 
			
		||||
 
 | 
			
		||||
         ssize_t readRet = 0, writeRet = 0;
 | 
			
		||||
         char data[1024]; /* Buffer to hold raw data from pty */
 | 
			
		||||
@@ -38,13 +18,12 @@ index b50ee9c..ad429ae 100644
 | 
			
		||||
 
 | 
			
		||||
         do
 | 
			
		||||
         {
 | 
			
		||||
@@ -343,8 +348,86 @@ int main(int argc, char *argv[])
 | 
			
		||||
@@ -206,8 +208,85 @@ int main(int argc, char *argv[])
 | 
			
		||||
             if (fds[0].revents & POLLIN)
 | 
			
		||||
             {
 | 
			
		||||
                 readRet = recv(ioSockets.inputSock, data, sizeof data, 0);
 | 
			
		||||
-                if (readRet > 0)
 | 
			
		||||
-                    writeRet = write(mfd_dp, data, readRet);
 | 
			
		||||
+
 | 
			
		||||
+                char * s = data;
 | 
			
		||||
+                int len = readRet;
 | 
			
		||||
+                writeRet = 1;
 | 
			
		||||
@@ -128,14 +107,13 @@ index b50ee9c..ad429ae 100644
 | 
			
		||||
 
 | 
			
		||||
             /* Resize window when buffer received in control socket */
 | 
			
		||||
diff --git a/src/wslbridge2.cpp b/src/wslbridge2.cpp
 | 
			
		||||
index 75ccb1b..e9fbbf7 100644
 | 
			
		||||
index 300ad57..3ba9096 100644
 | 
			
		||||
--- a/src/wslbridge2.cpp
 | 
			
		||||
+++ b/src/wslbridge2.cpp
 | 
			
		||||
@@ -56,32 +56,85 @@ union IoSockets
 | 
			
		||||
@@ -43,19 +43,41 @@ union IoSockets
 | 
			
		||||
 /* global variable */
 | 
			
		||||
 static union IoSockets g_ioSockets = { 0, 0, 0 };
 | 
			
		||||
 static volatile union IoSockets g_ioSockets = { 0 };
 | 
			
		||||
 
 | 
			
		||||
+
 | 
			
		||||
+#define dont_debug_inband
 | 
			
		||||
+#define dont_use_controlsocket
 | 
			
		||||
+
 | 
			
		||||
@@ -148,7 +126,7 @@ index 75ccb1b..e9fbbf7 100644
 | 
			
		||||
 
 | 
			
		||||
     /* Send terminal window size to control socket */
 | 
			
		||||
-    ioctl(STDIN_FILENO, TIOCGWINSZ, &winp);
 | 
			
		||||
     send(g_ioSockets.controlSock, &winp, sizeof winp, 0);
 | 
			
		||||
     send(g_ioSockets.controlSock, (char *)&winp, sizeof winp, 0);
 | 
			
		||||
+#else
 | 
			
		||||
+    static char wins[2 + sizeof(struct winsize)] = {0, 16};
 | 
			
		||||
+    static struct winsize * winsp = (struct winsize *)&wins[2];
 | 
			
		||||
@@ -171,27 +149,16 @@ index 75ccb1b..e9fbbf7 100644
 | 
			
		||||
 {
 | 
			
		||||
     int ret;
 | 
			
		||||
     char data[1024];
 | 
			
		||||
-
 | 
			
		||||
-    struct pollfd fds = { STDIN_FILENO, POLLIN, 0 };
 | 
			
		||||
+    assert(sizeof data <= PIPE_BUF);
 | 
			
		||||
 
 | 
			
		||||
     while (1)
 | 
			
		||||
     {
 | 
			
		||||
+#ifdef use_poll
 | 
			
		||||
+        // we could poll on a single channel but we don't need to
 | 
			
		||||
+        static struct pollfd fds = { STDIN_FILENO, POLLIN, 0 };
 | 
			
		||||
         ret = poll(&fds, 1, -1);
 | 
			
		||||
 
 | 
			
		||||
         if (fds.revents & POLLIN)
 | 
			
		||||
+#else
 | 
			
		||||
+        if (1)
 | 
			
		||||
+#endif
 | 
			
		||||
         {
 | 
			
		||||
             ret = read(STDIN_FILENO, data, sizeof data);
 | 
			
		||||
-            if (ret > 0)
 | 
			
		||||
-                ret = send(g_ioSockets.inputSock, data, ret, 0);
 | 
			
		||||
-            else
 | 
			
		||||
+
 | 
			
		||||
@@ -65,8 +87,33 @@ static void* send_buffer(void *param)
 | 
			
		||||
             closesocket(g_ioSockets.inputSock);
 | 
			
		||||
             break;
 | 
			
		||||
         }
 | 
			
		||||
-        if (!send(g_ioSockets.inputSock, data, ret, 0))
 | 
			
		||||
-            break;
 | 
			
		||||
+            char * s = data;
 | 
			
		||||
+            int len = ret;
 | 
			
		||||
+            while (ret > 0 && len > 0)
 | 
			
		||||
@@ -219,25 +186,27 @@ index 75ccb1b..e9fbbf7 100644
 | 
			
		||||
+                    }
 | 
			
		||||
+                }
 | 
			
		||||
+            }
 | 
			
		||||
+            if (ret <= 0)
 | 
			
		||||
                 break;
 | 
			
		||||
         }
 | 
			
		||||
     }
 | 
			
		||||
@@ -537,13 +590,6 @@ int main(int argc, char *argv[])
 | 
			
		||||
         closesocket(controlSocket);
 | 
			
		||||
     }
 | 
			
		||||
 
 | 
			
		||||
-    /* Create thread to send window size through control socket */
 | 
			
		||||
-    struct sigaction act = {};
 | 
			
		||||
     pthread_exit(&ret);
 | 
			
		||||
@@ -480,16 +527,6 @@ int main(int argc, char *argv[])
 | 
			
		||||
         g_ioSockets.controlSock = win_local_accept(controlSock);
 | 
			
		||||
     }
 | 
			
		||||
 
 | 
			
		||||
-    /* Capture window resize signal and send buffer to control socket */
 | 
			
		||||
-    {
 | 
			
		||||
-    struct sigaction act;
 | 
			
		||||
-    memset(&act, 0, sizeof act);
 | 
			
		||||
-    act.sa_handler = resize_window;
 | 
			
		||||
-    act.sa_flags = SA_RESTART;
 | 
			
		||||
-    ret = sigaction(SIGWINCH, &act, NULL);
 | 
			
		||||
-    assert(ret == 0);
 | 
			
		||||
-    }
 | 
			
		||||
-
 | 
			
		||||
     /* Create thread to send input buffer to input socket */
 | 
			
		||||
     pthread_t tidInput;
 | 
			
		||||
     ret = pthread_create(&tidInput, nullptr, send_buffer, nullptr);
 | 
			
		||||
@@ -556,6 +602,17 @@ int main(int argc, char *argv[])
 | 
			
		||||
@@ -502,6 +539,17 @@ int main(int argc, char *argv[])
 | 
			
		||||
 
 | 
			
		||||
     termState.enterRawMode();
 | 
			
		||||
 
 | 
			
		||||
 
 | 
			
		||||
@@ -291,6 +291,15 @@ config () {
 | 
			
		||||
  echoc "- root $root"
 | 
			
		||||
  wdir=%USERPROFILE%
 | 
			
		||||
 | 
			
		||||
  case "$name" in
 | 
			
		||||
  docker*)	echo skipping docker system
 | 
			
		||||
  		return;;
 | 
			
		||||
  esac
 | 
			
		||||
  case "$root" in
 | 
			
		||||
  *\\Docker*)	echo skipping docker system
 | 
			
		||||
  		return;;
 | 
			
		||||
  esac
 | 
			
		||||
 | 
			
		||||
  if $ok && ! $remove && [ -n "$distro" ]
 | 
			
		||||
  then	# fix #163: backend missing +x with certain mount options
 | 
			
		||||
	echo Setting +x wslbridge2 backends for distro "'$distro'"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								makefile
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								makefile
									
									
									
									
									
								
							@@ -10,16 +10,16 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# wsltty release
 | 
			
		||||
ver=3.4.5
 | 
			
		||||
ver=3.5.0.2
 | 
			
		||||
 | 
			
		||||
# wsltty appx release - must have 4 parts!
 | 
			
		||||
verx=3.4.5.0
 | 
			
		||||
verx=3.5.0.2
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
##############################
 | 
			
		||||
# mintty release version
 | 
			
		||||
 | 
			
		||||
minttyver=3.4.5
 | 
			
		||||
minttyver=3.5.0
 | 
			
		||||
 | 
			
		||||
##############################
 | 
			
		||||
 | 
			
		||||
@@ -27,7 +27,7 @@ minttyver=3.4.5
 | 
			
		||||
repo=Biswa96/wslbridge2
 | 
			
		||||
 | 
			
		||||
# wslbridge2 master release version
 | 
			
		||||
wslbridgever=0.6
 | 
			
		||||
wslbridgever=0.8
 | 
			
		||||
 | 
			
		||||
# wslbridge2 latest version
 | 
			
		||||
#archive=master
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user