[newlib-cygwin] Cygwin: pipe: Add missing code restoring real_non_blocking_mode

Takashi Yano via Cygwin-cvs <[email protected]>
Newsgroups gmane.os.cygwin.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=bc95e1bef29b7b1c9be00f8cd342d303466ee350

commit bc95e1bef29b7b1c9be00f8cd342d303466ee350
Author: Takashi Yano <[email protected]>
Date:   Tue Jul 1 02:49:32 2025 +0900

    Cygwin: pipe: Add missing code restoring real_non_blocking_mode
    
    Fixes: 940dbeffa713 ("Cygwin: pipe: Fix unexpected blocking mode change by pipe_data_available()")
    Reported by: Andrew Ng <[email protected]>
    Signed-off-by: Takashi Yano <[email protected]>

Diff:
---
 winsup/cygwin/fhandler/pipe.cc | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/fhandler/pipe.cc b/winsup/cygwin/fhandler/pipe.cc
index 1a8c39c5b..2312688e1 100644
--- a/winsup/cygwin/fhandler/pipe.cc
+++ b/winsup/cygwin/fhandler/pipe.cc
@@ -392,7 +392,10 @@ fhandler_pipe::raw_read (void *ptr, size_t& len)
       status = NtReadFile (get_handle (), NULL, NULL, NULL, &io, ptr,
 			   len1, NULL, NULL);
       if (real_non_blocking_mode)
-	set_pipe_non_blocking (false);
+	{
+	  set_pipe_non_blocking (false);
+	  real_non_blocking_mode = false;
+	}
       if (isclosed ())  /* A signal handler might have closed the fd. */
 	{
 	  set_errno (EBADF);
@@ -702,7 +705,10 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len)
     }
 
   if (real_non_blocking_mode)
-    ((fhandler_pipe *) this)->set_pipe_non_blocking (false);
+    {
+      ((fhandler_pipe *) this)->set_pipe_non_blocking (false);
+      real_non_blocking_mode = false;
+    }
 
   CloseHandle (evt);
   if (pipe_mtx) /* pipe_mtx is NULL in the fifo case */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.