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

This commit is contained in:
Takashi Yano 2021-09-12 15:06:05 +09:00 committed by Corinna Vinschen
parent 0b538118b2
commit 0063ffeb73
2 changed files with 14 additions and 0 deletions

View File

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

View File

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