From e0d2711c907d92c5827767747457f830ac5d70cc Mon Sep 17 00:00:00 2001 From: jsorg71 Date: Sat, 23 Sep 2006 01:57:16 +0000 Subject: [PATCH] win32 thread creation fix --- common/thread_calls.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/common/thread_calls.c b/common/thread_calls.c index 578bc0b9..c895a5d5 100644 --- a/common/thread_calls.c +++ b/common/thread_calls.c @@ -28,13 +28,20 @@ #include "arch.h" /*****************************************************************************/ +/* returns error */ #if defined(_WIN32) int APP_CC g_thread_create(unsigned long (__stdcall * start_routine)(void*), void* arg) { - DWORD thread; + DWORD thread_id; + HANDLE thread; + int rv; - return !CreateThread(0, 0, start_routine, arg, 0, &thread); + /* CreateThread returns handle or zero on error */ + thread = CreateThread(0, 0, start_routine, arg, 0, &thread_id); + rv = !thread; + CloseHandle(thread); + return rv; } #else int APP_CC @@ -43,6 +50,7 @@ g_thread_create(void* (* start_routine)(void*), void* arg) pthread_t thread; int rv; + /* pthread_create returns error */ rv = pthread_create(&thread, 0, start_routine, arg); pthread_detach(thread); return rv;