public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: pipe: Fix deadlock if pipe is created by non-cygwin app.
@ 2021-09-14 15:07 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2021-09-14 15:07 UTC (permalink / raw)
  To: cygwin-cvs

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

commit 0063ffeb739189b937097901cca4d5c67e8e5203
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Sun Sep 12 15:06:05 2021 +0900

    Cygwin: pipe: Fix deadlock if pipe is created by non-cygwin app.

Diff:
---
 winsup/cygwin/fhandler.h       |  1 +
 winsup/cygwin/fhandler_pipe.cc | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index d309be2f7..13fba9a14 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1205,6 +1205,7 @@ public:
   select_record *select_except (select_stuff *);
   char *get_proc_fd_name (char *buf);
   int open (int flags, mode_t mode = 0);
+  void open_setup (int flags);
   void fixup_after_fork (HANDLE);
   int dup (fhandler_base *child, int);
   int close ();
diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc
index 6994a5dce..9b4255cfd 100644
--- a/winsup/cygwin/fhandler_pipe.cc
+++ b/winsup/cygwin/fhandler_pipe.cc
@@ -191,6 +191,19 @@ out:
   return 0;
 }
 
+void
+fhandler_pipe::open_setup (int flags)
+{
+  fhandler_base::open_setup (flags);
+  if (get_dev () == FH_PIPER && !read_mtx)
+    {
+      SECURITY_ATTRIBUTES *sa = sec_none_cloexec (flags);
+      read_mtx = CreateMutex (sa, FALSE, NULL);
+      if (!read_mtx)
+	debug_printf ("CreateMutex failed: %E");
+    }
+}
+
 off_t
 fhandler_pipe::lseek (off_t offset, int whence)
 {


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-14 15:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 15:07 [newlib-cygwin] Cygwin: pipe: Fix deadlock if pipe is created by non-cygwin app Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).