aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/select.cc
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2021-09-10 08:43:59 +0900
committerCorinna Vinschen <corinna@vinschen.de>2021-09-13 17:45:55 +0200
commit0b538118b2f883919bbf7050d1bf7a978b569a66 (patch)
tree824f1136546430ed8b1e97e037ec87b555fc12e1 /winsup/cygwin/select.cc
parentba4c58299f642b525de1a681dd8ad05b61dc8e49 (diff)
downloadnewlib-0b538118b2f883919bbf7050d1bf7a978b569a66.zip
newlib-0b538118b2f883919bbf7050d1bf7a978b569a66.tar.gz
newlib-0b538118b2f883919bbf7050d1bf7a978b569a66.tar.bz2
Cygwin: fifo: Utilize select_sem for fifo as well as pipe.
Diffstat (limited to 'winsup/cygwin/select.cc')
-rw-r--r--winsup/cygwin/select.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index e9e71b2..5e58343 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -963,7 +963,13 @@ start_thread_fifo (select_record *me, select_stuff *stuff)
{
pi->start = &stuff->start;
pi->stop_thread = false;
- pi->bye = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
+ pi->bye = me->fh->get_select_sem ();
+ if (pi->bye)
+ DuplicateHandle (GetCurrentProcess (), pi->bye,
+ GetCurrentProcess (), &pi->bye,
+ 0, 0, DUPLICATE_SAME_ACCESS);
+ else
+ pi->bye = CreateSemaphore (&sec_none_nih, 0, INT32_MAX, NULL);
pi->thread = new cygthread (thread_fifo, pi, "fifosel");
me->h = *pi->thread;
if (!me->h)
@@ -981,7 +987,7 @@ fifo_cleanup (select_record *, select_stuff *stuff)
if (pi->thread)
{
pi->stop_thread = true;
- SetEvent (pi->bye);
+ ReleaseSemaphore (pi->bye, get_obj_handle_count (pi->bye), NULL);
pi->thread->detach ();
CloseHandle (pi->bye);
}