summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-03-27 09:10:57 -0400
committerBen Gamari <ben@smart-cactus.org>2021-03-27 09:12:57 -0400
commit63a5c876657bb89e9847f325fb81df2229297eb3 (patch)
tree016b4d8e29aafd61391660260cb7c73c53616d95
parent0d5d344d45c200a5e731e7d067598acd2a4f7050 (diff)
downloadhaskell-wip/joinOSThread.tar.gz
rts: Fix joinOSThread on Windowswip/joinOSThread
Previously we were treating the thread ID as a HANDLE, but it is not. We must first OpenThread.
-rw-r--r--rts/win32/OSThreads.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/rts/win32/OSThreads.c b/rts/win32/OSThreads.c
index 07b0e3f034..46e363b3ab 100644
--- a/rts/win32/OSThreads.c
+++ b/rts/win32/OSThreads.c
@@ -447,7 +447,12 @@ interruptOSThread (OSThreadId id)
void
joinOSThread (OSThreadId id)
{
- int ret = WaitForSingleObject(id, INFINITE);
+ HANDLE hdl;
+ if (!(hdl = OpenThread(SYNCHRONIZE,FALSE,id))) {
+ sysErrorBelch("interruptOSThread: OpenThread");
+ stg_exit(EXIT_FAILURE);
+ }
+ int ret = WaitForSingleObject(hdl, INFINITE);
if (ret != WAIT_OBJECT_0) {
sysErrorBelch("joinOSThread: error %d", ret);
}