From 51f7c9d15ed4af06f39f863c253252f77336d0e9 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 30 Mar 2021 20:32:15 +0300 Subject: [PATCH] ntdll: Close server socket before calling exit(). So if a native exit handler hangs the process eventually gets killed by server. Signed-off-by: Paul Gofman Signed-off-by: Alexandre Julliard --- dlls/ntdll/unix/server.c | 12 ++++++++++++ dlls/ntdll/unix/thread.c | 2 +- dlls/ntdll/unix/unix_private.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c index 3f446e8348a..50d89f79c0d 100644 --- a/dlls/ntdll/unix/server.c +++ b/dlls/ntdll/unix/server.c @@ -1470,6 +1470,18 @@ static void init_teb64( TEB *teb ) #endif } +/*********************************************************************** + * process_exit_wrapper + * + * Close server socket and exit process normally. + */ +void process_exit_wrapper( int status ) +{ + close( fd_socket ); + exit( status ); +} + + /*********************************************************************** * server_init_process * diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index 00d29ae706b..1a882a99855 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -329,7 +329,7 @@ static void exit_thread( int status ) void exit_process( int status ) { pthread_sigmask( SIG_BLOCK, &server_block_set, NULL ); - signal_exit_thread( get_unix_exit_code( status ), exit ); + signal_exit_thread( get_unix_exit_code( status ), process_exit_wrapper ); } diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 3987cc6c4d0..b49789b641e 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -164,6 +164,7 @@ extern unsigned int server_queue_process_apc( HANDLE process, const apc_call_t * apc_result_t *result ) DECLSPEC_HIDDEN; extern int server_get_unix_fd( HANDLE handle, unsigned int wanted_access, int *unix_fd, int *needs_close, enum server_fd_type *type, unsigned int *options ) DECLSPEC_HIDDEN; +extern void process_exit_wrapper( int status ) DECLSPEC_HIDDEN; extern size_t server_init_process(void) DECLSPEC_HIDDEN; extern void server_init_process_done(void) DECLSPEC_HIDDEN; extern void server_init_thread( void *entry_point, BOOL *suspend ) DECLSPEC_HIDDEN;