From: Seija Kijin <doremylover123@xxxxxxxxx> After joining threads, the handle to the original thread should be closed as it no longer needs to be open. This change makes the function POSIX compliant. Signed-off-by: Seija Kijin <doremylover123@xxxxxxxxx> --- compat/win32/pthread.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c index 2e7eead42cb..cf94b4491f9 100644 --- a/compat/win32/pthread.c +++ b/compat/win32/pthread.c @@ -37,16 +37,18 @@ int pthread_create(pthread_t *thread, const void *unused, int win32_pthread_join(pthread_t *thread, void **value_ptr) { - DWORD result = WaitForSingleObject(thread->handle, INFINITE); - switch (result) { - case WAIT_OBJECT_0: - if (value_ptr) - *value_ptr = thread->arg; - return 0; - case WAIT_ABANDONED: - return EINVAL; - default: - return err_win_to_posix(GetLastError()); + switch (WaitForSingleObject(thread->handle, INFINITE)) { + case WAIT_OBJECT_0: + if (value_ptr) + *value_ptr = thread->arg; + CloseHandle(thread->handle); + return 0; + case WAIT_ABANDONED: + CloseHandle(thread->handle); + return EINVAL; + default: + /* the function failed, so do not detach */ + return err_win_to_posix(GetLastError()); } } -- gitgitgadget