exit:
set_event(thread);
- thread->dwExitCode = (DWORD)(size_t)rc;
+
+ if (!thread->exited)
+ thread->dwExitCode = (DWORD)(size_t)rc;
if (thread->detached || !thread->started)
cleanup_handle(thread);
}
else
cleanup_handle(thread);
+
ListDictionary_Unlock(thread_list);
if (ListDictionary_Count(thread_list) < 1)
VOID ExitThread(DWORD dwExitCode)
{
-#if defined(WITH_DEBUG_THREADS) && defined(HAVE_EXECINFO_H)
pthread_t tid = pthread_self();
if (NULL == thread_list)
ListDictionary_Lock(thread_list);
thread = ListDictionary_GetItemValue(thread_list, &tid);
assert(thread);
+ thread->exited = TRUE;
+ thread->dwExitCode = dwExitCode;
+#if defined(WITH_DEBUG_THREADS) && defined(HAVE_EXECINFO_H)
backtrace(thread->exit_stack, 20);
+#endif
ListDictionary_Unlock(thread_list);
}
-
-#endif
- fprintf(stderr, "[%s] terminated...\n", __FUNCTION__);
}
BOOL GetExitCodeThread(HANDLE hThread, LPDWORD lpExitCode)
if (keys)
free(keys);
+
ListDictionary_Unlock(thread_list);
}
#include "../handle/handle.h"
-typedef void *(*pthread_start_routine)(void*);
+typedef void *(*pthread_start_routine)(void *);
struct winpr_thread
{
int pipe_fd[2];
BOOL mainProcess;
BOOL detached;
+ BOOL exited;
DWORD dwExitCode;
pthread_t thread;
SIZE_T dwStackSize;