[PATCH 4/4] Cygwin: pty: Revise the code which prevents undesired window title.

Takashi Yano takashi.yano@nifty.ne.jp
Sun May 31 05:53:20 GMT 2020


- In current pty, the window title can not be set from non-cygwin
  program due to the code which prevents overwriting the window
  title to "cygwin-console-helper.exe" in fhandler_pty_master::pty_
  master_fwd_thread(). This patch fixes the issue.
---
 winsup/cygwin/fhandler_tty.cc | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index c3d49968d..e434b7878 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -3313,9 +3313,14 @@ fhandler_pty_master::pty_master_fwd_thread ()
 	      }
 	    else if (state == 4 && outbuf[i] == '\a')
 	      {
-		memmove (&outbuf[start_at], &outbuf[i+1], rlen-i-1);
+		const char *helper_str = "\\bin\\cygwin-console-helper.exe";
+		if (memmem (&outbuf[start_at], i + 1 - start_at,
+			    helper_str, strlen (helper_str)))
+		  {
+		    memmove (&outbuf[start_at], &outbuf[i+1], rlen-i-1);
+		    rlen = wlen = start_at + rlen - i - 1;
+		  }
 		state = 0;
-		rlen = wlen = start_at + rlen - i - 1;
 		continue;
 	      }
 	    else if (outbuf[i] == '\a')
-- 
2.26.2



More information about the Cygwin-patches mailing list