win32: close handles of threads that have been joined

After the thread terminates, the handle to the original thread should be closed. This change makes win32_pthread_join POSIX compliant. Signed-off-by: Seija Kijin <doremylover123@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Seija Kijin committed Jan 3, 2023 at 16:20 UTC 238a9dfe86d18214bc0b8be079feee01a2fdc407
1 file changed +3
compat/win32/pthread.c
+3
@@ -42,10 +42,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)
42 case WAIT_OBJECT_0:
43 if (value_ptr)
44 *value_ptr = thread->arg;
45 + CloseHandle(thread->handle);
46 return 0;
47 case WAIT_ABANDONED:
48 + CloseHandle(thread->handle);
49 return EINVAL;
50 default:
51 + /* the wait failed, so do not detach */
52 return err_win_to_posix(GetLastError());
53 }
54 }