diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 2fc240ae296..297a1b79efb 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -81,26 +81,11 @@ void WINAPI RtlExitUserThread( ULONG status ) { ULONG last; - if (status) /* send the exit code to the server (0 is already the default) */ - { - SERVER_START_REQ( terminate_thread ) - { - req->handle = wine_server_obj_handle( GetCurrentThread() ); - req->exit_code = status; - wine_server_call( req ); - } - SERVER_END_REQ; - } - NtQueryInformationThread( GetCurrentThread(), ThreadAmILastThread, &last, sizeof(last), NULL ); - if (last) - { - LdrShutdownProcess(); - unix_funcs->exit_process( status ); - } + if (last) RtlExitUserProcess( status ); LdrShutdownThread(); RtlFreeThreadActivationContextStack(); - for (;;) unix_funcs->exit_thread( status ); + for (;;) NtTerminateThread( GetCurrentThread(), status ); } diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 3f3a10155d2..dc4a5791321 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1404,8 +1404,6 @@ static struct unix_funcs unix_funcs = virtual_locked_recvmsg, virtual_release_address_space, virtual_set_large_address_space, - exit_thread, - exit_process, exec_process, wine_server_call, server_send_fd, diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index 83c67737f8b..9854f13aba6 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -1002,6 +1002,7 @@ done: */ NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code ) { + static BOOL clean_exit; NTSTATUS ret; BOOL self; @@ -1013,7 +1014,12 @@ NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code ) self = reply->self; } SERVER_END_REQ; - if (self && handle) abort_process( exit_code ); + if (self) + { + if (!handle) clean_exit = TRUE; + else if (clean_exit) exit_process( exit_code ); + else abort_process( exit_code ); + } return ret; } diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index 3b451a22577..8ade2d9c784 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -298,7 +298,7 @@ void abort_process( int status ) /*********************************************************************** * exit_thread */ -void CDECL exit_thread( int status ) +static void exit_thread( int status ) { static void *prev_teb; TEB *teb; @@ -322,7 +322,7 @@ void CDECL exit_thread( int status ) /*********************************************************************** * exit_process */ -void CDECL exit_process( int status ) +void exit_process( int status ) { pthread_sigmask( SIG_BLOCK, &server_block_set, NULL ); signal_exit_thread( get_unix_exit_code( status ), exit ); @@ -525,7 +525,7 @@ NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code ) } SERVER_END_REQ; } - if (self) abort_thread( exit_code ); + if (self) exit_thread( exit_code ); return ret; } diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 60883bfa39b..50f27c6d681 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -120,8 +120,6 @@ extern NTSTATUS CDECL server_handle_to_fd( HANDLE handle, unsigned int access, i unsigned int *options ) DECLSPEC_HIDDEN; extern void CDECL server_release_fd( HANDLE handle, int unix_fd ) DECLSPEC_HIDDEN; extern void CDECL server_init_process_done( void *relay ) DECLSPEC_HIDDEN; -extern void CDECL DECLSPEC_NORETURN exit_thread( int status ) DECLSPEC_HIDDEN; -extern void CDECL DECLSPEC_NORETURN exit_process( int status ) DECLSPEC_HIDDEN; extern NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status ) DECLSPEC_HIDDEN; extern NTSTATUS CDECL unwind_builtin_dll( ULONG type, struct _DISPATCHER_CONTEXT *dispatch, CONTEXT *context ) DECLSPEC_HIDDEN; @@ -181,6 +179,7 @@ extern NTSTATUS context_to_server( context_t *to, const CONTEXT *from ) DECLSPEC extern NTSTATUS context_from_server( CONTEXT *to, const context_t *from ) DECLSPEC_HIDDEN; extern void DECLSPEC_NORETURN abort_thread( int status ) DECLSPEC_HIDDEN; extern void DECLSPEC_NORETURN abort_process( int status ) DECLSPEC_HIDDEN; +extern void DECLSPEC_NORETURN exit_process( int status ) DECLSPEC_HIDDEN; extern void wait_suspend( CONTEXT *context ) DECLSPEC_HIDDEN; extern NTSTATUS send_debug_event( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance ) DECLSPEC_HIDDEN; extern NTSTATUS set_thread_context( HANDLE handle, const context_t *context, BOOL *self ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h index 84e1a27977a..118f38a2488 100644 --- a/dlls/ntdll/unixlib.h +++ b/dlls/ntdll/unixlib.h @@ -28,7 +28,7 @@ struct msghdr; struct _DISPATCHER_CONTEXT; /* increment this when you change the function table */ -#define NTDLL_UNIXLIB_VERSION 90 +#define NTDLL_UNIXLIB_VERSION 91 struct unix_funcs { @@ -97,8 +97,6 @@ struct unix_funcs void (CDECL *virtual_set_large_address_space)(void); /* thread/process functions */ - void (CDECL *exit_thread)( int status ); - void (CDECL *exit_process)( int status ); NTSTATUS (CDECL *exec_process)( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status ); /* server functions */