diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index c9c79fb6496..80bca0ca3d0 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -69,6 +69,8 @@ extern void signal_init_thread( TEB *teb ) DECLSPEC_HIDDEN; extern void signal_init_process(void) DECLSPEC_HIDDEN; extern void signal_start_thread( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend ) DECLSPEC_HIDDEN; extern void signal_start_process( LPTHREAD_START_ROUTINE entry, BOOL suspend ) DECLSPEC_HIDDEN; +extern void DECLSPEC_NORETURN signal_exit_thread( int status ) DECLSPEC_HIDDEN; +extern void DECLSPEC_NORETURN signal_exit_process( int status ) DECLSPEC_HIDDEN; extern void version_init( const WCHAR *appname ) DECLSPEC_HIDDEN; extern void debug_init(void) DECLSPEC_HIDDEN; extern HANDLE thread_init(void) DECLSPEC_HIDDEN; @@ -86,7 +88,6 @@ extern void server_init_process(void) DECLSPEC_HIDDEN; extern void server_init_process_done(void) DECLSPEC_HIDDEN; extern size_t server_init_thread( void *entry_point, BOOL *suspend ) DECLSPEC_HIDDEN; extern void DECLSPEC_NORETURN abort_thread( int status ) DECLSPEC_HIDDEN; -extern void DECLSPEC_NORETURN terminate_thread( int status ) DECLSPEC_HIDDEN; extern void DECLSPEC_NORETURN exit_thread( int status ) DECLSPEC_HIDDEN; extern sigset_t server_block_set DECLSPEC_HIDDEN; extern unsigned int server_call_unlocked( void *req_ptr ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/signal_arm.c b/dlls/ntdll/signal_arm.c index 64ff1e010e4..dcb45646408 100644 --- a/dlls/ntdll/signal_arm.c +++ b/dlls/ntdll/signal_arm.c @@ -1233,7 +1233,7 @@ static void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg ) __TRY { TRACE_(relay)( "\1Starting thread proc %p (arg=%p)\n", entry, arg ); - exit_thread( entry( arg )); + RtlExitUserThread( entry( arg )); } __EXCEPT(unhandled_exception_filter) { @@ -1302,19 +1302,19 @@ void signal_start_process( LPTHREAD_START_ROUTINE entry, BOOL suspend ) } /*********************************************************************** - * RtlExitUserThread (NTDLL.@) + * signal_exit_thread */ -void WINAPI RtlExitUserThread( ULONG status ) +void signal_exit_thread( int status ) { exit_thread( status ); } /*********************************************************************** - * abort_thread + * signal_exit_process */ -void abort_thread( int status ) +void signal_exit_process( int status ) { - terminate_thread( status ); + exit( status ); } /********************************************************************** diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c index 6905ab4362a..a04fe93a575 100644 --- a/dlls/ntdll/signal_arm64.c +++ b/dlls/ntdll/signal_arm64.c @@ -965,7 +965,7 @@ static void WINAPI call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void * __TRY { TRACE_(relay)( "\1Starting thread proc %p (arg=%p)\n", entry, arg ); - exit_thread( entry( arg )); + RtlExitUserThread( entry( arg )); } __EXCEPT(unhandled_exception_filter) { @@ -1034,19 +1034,19 @@ void signal_start_process( LPTHREAD_START_ROUTINE entry, BOOL suspend ) } /*********************************************************************** - * RtlExitUserThread (NTDLL.@) + * signal_exit_thread */ -void WINAPI RtlExitUserThread( ULONG status ) +void signal_exit_thread( int status ) { exit_thread( status ); } /*********************************************************************** - * abort_thread + * signal_exit_process */ -void abort_thread( int status ) +void signal_exit_process( int status ) { - terminate_thread( status ); + exit( status ); } /********************************************************************** diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index 351b67c8916..4be573edd17 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -2989,21 +2989,21 @@ void signal_start_process( LPTHREAD_START_ROUTINE entry, BOOL suspend ) /*********************************************************************** - * RtlExitUserThread (NTDLL.@) + * signal_exit_thread */ -void WINAPI RtlExitUserThread( ULONG status ) +void signal_exit_thread( int status ) { if (!x86_thread_data()->exit_frame) exit_thread( status ); call_thread_exit_func( status, exit_thread, x86_thread_data()->exit_frame ); } /*********************************************************************** - * abort_thread + * signal_exit_process */ -void abort_thread( int status ) +void signal_exit_process( int status ) { - if (!x86_thread_data()->exit_frame) terminate_thread( status ); - call_thread_exit_func( status, terminate_thread, x86_thread_data()->exit_frame ); + if (!x86_thread_data()->exit_frame) exit( status ); + call_thread_exit_func( status, exit, x86_thread_data()->exit_frame ); } /********************************************************************** diff --git a/dlls/ntdll/signal_powerpc.c b/dlls/ntdll/signal_powerpc.c index 234fdc4d478..3182a13d370 100644 --- a/dlls/ntdll/signal_powerpc.c +++ b/dlls/ntdll/signal_powerpc.c @@ -1143,7 +1143,7 @@ static void WINAPI call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void * __TRY { TRACE_(relay)( "\1Starting thread proc %p (arg=%p)\n", entry, arg ); - exit_thread( entry( arg )); + RtlExitUserThread( entry( arg )); } __EXCEPT(unhandled_exception_filter) { @@ -1212,19 +1212,19 @@ void signal_start_process( LPTHREAD_START_ROUTINE entry, BOOL suspend ) } /*********************************************************************** - * RtlExitUserThread (NTDLL.@) + * signal_exit_thread */ -void WINAPI RtlExitUserThread( ULONG status ) +void signal_exit_thread( int status ) { exit_thread( status ); } /*********************************************************************** - * abort_thread + * signal_exit_process */ -void abort_thread( int status ) +void signal_exit_process( int status ) { - terminate_thread( status ); + exit( status ); } /********************************************************************** diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index c955c4c573a..1f7664051ab 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -4160,21 +4160,21 @@ void signal_start_process( LPTHREAD_START_ROUTINE entry, BOOL suspend ) /*********************************************************************** - * RtlExitUserThread (NTDLL.@) + * signal_exit_thread */ -void WINAPI RtlExitUserThread( ULONG status ) +void signal_exit_thread( int status ) { if (!amd64_thread_data()->exit_frame) exit_thread( status ); call_thread_exit_func( status, exit_thread, amd64_thread_data()->exit_frame ); } /*********************************************************************** - * abort_thread + * signal_exit_process */ -void abort_thread( int status ) +void signal_exit_process( int status ) { - if (!amd64_thread_data()->exit_frame) terminate_thread( status ); - call_thread_exit_func( status, terminate_thread, amd64_thread_data()->exit_frame ); + if (!amd64_thread_data()->exit_frame) exit( status ); + call_thread_exit_func( status, exit, amd64_thread_data()->exit_frame ); } /********************************************************************** diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 7b726ab7010..6abfd856520 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -426,13 +426,21 @@ static void free_thread_data( TEB *teb ) /*********************************************************************** - * terminate_thread + * abort_thread */ -void terminate_thread( int status ) +void abort_thread( int status ) { pthread_sigmask( SIG_BLOCK, &server_block_set, NULL ); if (interlocked_xchg_add( &nb_threads, -1 ) <= 1) _exit( status ); + signal_exit_thread( status ); +} + +/*********************************************************************** + * exit_thread + */ +void exit_thread( int status ) +{ close( ntdll_get_thread_data()->wait_fd[0] ); close( ntdll_get_thread_data()->wait_fd[1] ); close( ntdll_get_thread_data()->reply_fd ); @@ -442,9 +450,9 @@ void terminate_thread( int status ) /*********************************************************************** - * exit_thread + * RtlExitUserThread (NTDLL.@) */ -void exit_thread( int status ) +void WINAPI RtlExitUserThread( ULONG status ) { static void *prev_teb; TEB *teb; @@ -463,7 +471,7 @@ void exit_thread( int status ) if (interlocked_xchg_add( &nb_threads, -1 ) <= 1) { LdrShutdownProcess(); - exit( status ); + signal_exit_process( status ); } LdrShutdownThread(); @@ -482,11 +490,7 @@ void exit_thread( int status ) } } - close( ntdll_get_thread_data()->wait_fd[0] ); - close( ntdll_get_thread_data()->wait_fd[1] ); - close( ntdll_get_thread_data()->reply_fd ); - close( ntdll_get_thread_data()->request_fd ); - pthread_exit( UIntToPtr(status) ); + signal_exit_thread( status ); }