https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=224317ed81a603fa60103f6ff69d13029ee38179

commit 224317ed81a603fa60103f6ff69d13029ee38179
Author: Takashi Yano <[email protected]>
Date:   Sun Mar 1 03:59:11 2026 +0900

    Cygwin: pty: Do not call empty WriteFile() to to_slave_nat
    
    In Windows 11, it seems that conhost.exe crashes on WriteFile() of
    zero-length data to to_slave_nat. This patch skip WriteFile() if
    the data length is 0.
    
    Signed-off-by: Takashi Yano <[email protected]>
    Reviewed-by: Johannes Schindelin <[email protected]>

Diff:
---
 winsup/cygwin/fhandler/pty.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc
index 90f58671c..026011984 100644
--- a/winsup/cygwin/fhandler/pty.cc
+++ b/winsup/cygwin/fhandler/pty.cc
@@ -2240,7 +2240,8 @@ fhandler_pty_master::write (const void *ptr, size_t len)
        }
 
       DWORD n;
-      WriteFile (to_slave_nat, buf, nlen, &n, NULL);
+      if (nlen)
+       WriteFile (to_slave_nat, buf, nlen, &n, NULL);
       ReleaseMutex (input_mutex);
 
       return len;

Reply via email to