summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2019-04-20 11:49:35 -0400
committerKen Brown <kbrown@cornell.edu>2019-04-20 14:31:07 -0400
commitef269531a96b649ae27395f272cf95aa2c7062fa (patch)
tree22d83cf0ec9c4e51d35950142f25c15b25e771a7
parent4ecea14a5800e2f134f6e61d4eb8720982782a43 (diff)
downloadcygnal-ef269531a96b649ae27395f272cf95aa2c7062fa.tar.gz
cygnal-ef269531a96b649ae27395f272cf95aa2c7062fa.tar.bz2
cygnal-ef269531a96b649ae27395f272cf95aa2c7062fa.zip
Cygwin: FIFO: duplicate the i/o handle when opening a duplexer
Don't use the same i/o handle for the first client handler as is used for the fhandler itself; this can lead to a later attempt to close the same handle twice. Instead use a duplicate.
-rw-r--r--winsup/cygwin/fhandler_fifo.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index 409144fda..0a6dc0591 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -480,7 +480,14 @@ fhandler_fifo::open (int flags, mode_t)
res = error_errno_set;
goto out;
}
- fh->set_handle (ph);
+ if (!DuplicateHandle (GetCurrentProcess (), ph, GetCurrentProcess (),
+ &fh->get_handle (), 0, true, DUPLICATE_SAME_ACCESS))
+ {
+ res = error_set_errno;
+ fh->close ();
+ delete fh;
+ goto out;
+ }
fh->set_flags (flags);
if (!(connect_evt = create_event ()))
{