From: Rémi Bernon rbernon@codeweavers.com
So that we can safely call pthread_exit from the unix main thread, and wait for all other threads to exit. The last win32 thread will actually terminate the process directly by calling _exit.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52213 --- dlls/ntdll/unix/loader.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index c21d32ea811..f3daa14f7f0 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -2148,10 +2148,7 @@ static struct unix_funcs unix_funcs = };
-/*********************************************************************** - * start_main_thread - */ -static void start_main_thread(void) +static void *main_thread( void *arg ) { SYSTEM_SERVICE_TABLE syscall_table = { (ULONG_PTR *)syscalls, NULL, ARRAY_SIZE(syscalls), syscall_args }; NTSTATUS status; @@ -2185,6 +2182,20 @@ static void start_main_thread(void) NtTerminateProcess( GetCurrentProcess(), status ); } server_init_process_done(); + return 0; +} + +/*********************************************************************** + * start_main_thread + */ +static void start_main_thread(void) +{ + pthread_t thread; + void *ret; + + pthread_create( &thread, NULL, main_thread, NULL ); + pthread_join( thread, &ret ); + pthread_exit( ret ); }
#ifdef __ANDROID__