[PATCH 3/3] ntdll: Close server socket before calling exit().
Paul Gofman
pgofman at codeweavers.com
Tue Mar 30 12:32:15 CDT 2021
So if a native exit handler hangs the process eventually gets killed by server.
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
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 1557aa2371a..a934610e3c0 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;
--
2.30.2
More information about the wine-devel
mailing list