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.
This commit is contained in:
Ken Brown 2019-04-20 11:49:35 -04:00
parent 4ecea14a58
commit ef269531a9
1 changed files with 8 additions and 1 deletions

View File

@ -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 ()))
{