]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0028: win32: Ctrl-D cannot be used to close a pipe v9.1.0028
authorGuyBrush <miguel.barro@live.com>
Sun, 14 Jan 2024 19:08:40 +0000 (20:08 +0100)
committerChristian Brabandt <cb@256bit.org>
Sun, 14 Jan 2024 19:08:40 +0000 (20:08 +0100)
Problem:  win32: Ctrl-D cannot be used to close a pipe
Solution: Properly detect Ctrl-D when reading from a pipe
          (GuyBrush)

Enabling Ctrl-D for gvim pipeline input
and apply defensive programming on account of PR #12752
so that once PR 12752 is merged, CTRL-D will keep on working

closes: #13849

Signed-off-by: GuyBrush <miguel.barro@live.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/os_win32.c
src/version.c

index dbfc4eeca70fc5b9c2d749ab7c5d88c6d9bf9bcd..3f2b3c3a4ca20d43b38c125e646016a4731d4db0 100644 (file)
@@ -5176,7 +5176,7 @@ mch_system_piped(char *cmd, int options)
                {
                    /*
                     * For pipes: Check for CTRL-C: send interrupt signal to
-                    * child.  Check for CTRL-D: EOF, close pipe to child.
+                    * child.
                     */
                    if (len == 1 && cmd != NULL)
                    {
@@ -5186,10 +5186,22 @@ mch_system_piped(char *cmd, int options)
                        // now put 9 as SIGKILL
                            TerminateProcess(pi.hProcess, 9);
                        }
-                       if (ta_buf[ta_len] == Ctrl_D)
+                   }
+
+                   /*
+                    * Check for CTRL-D: EOF, close pipe to child.
+                    * Ctrl_D may be decorated by _OnChar()
+                    */
+                   if ((len == 1 || len == 4 ) && cmd != NULL)
+                   {
+                       if (ta_buf[0] == Ctrl_D
+                           || (ta_buf[0] == CSI
+                               && ta_buf[1] == KS_MODIFIER
+                               && ta_buf[3] == Ctrl_D))
                        {
                            CloseHandle(g_hChildStd_IN_Wr);
                            g_hChildStd_IN_Wr = NULL;
+                           len = 0;
                        }
                    }
 
index a17ae156b28397ddefe79aa6d3205871c8fd9e94..f01cac8b7c9413a120b088f17e6f8a2ebd9e9bcf 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    28,
 /**/
     27,
 /**/