Signed-off-by: Paul Gofman pgofman@codeweavers.com --- The series avoids process being left alive on normal process termination if some of the native exit handlers hang.
I hope it might fix https://bugs.winehq.org/show_bug.cgi?id=49897 but I am mostly unable to reproduce that here so cannot verify.
server/process.c | 5 ----- 1 file changed, 5 deletions(-)
diff --git a/server/process.c b/server/process.c index 7bc096a7b1f..9a647e7eddc 100644 --- a/server/process.c +++ b/server/process.c @@ -946,12 +946,7 @@ void kill_process( struct process *process, int violent_death ) }
if (process->sigkill_timeout) /* already waiting for it to die */ - { - remove_timeout_user( process->sigkill_timeout ); - process->sigkill_timeout = NULL; - process_died( process ); return; - }
if (violent_death) terminate_process( process, NULL, 1 ); else
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- server/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/process.c b/server/process.c index 9a647e7eddc..634e8167be6 100644 --- a/server/process.c +++ b/server/process.c @@ -503,7 +503,7 @@ static void process_sigkill( void *private ) static void start_sigkill_timer( struct process *process ) { grab_object( process ); - if (process->unix_pid != -1 && process->msg_fd) + if (process->unix_pid != -1) process->sigkill_timeout = add_timeout_user( -TICKS_PER_SEC, process_sigkill, process ); else process_died( process );
So if a native exit handler hangs the process eventually gets killed by server.
Signed-off-by: Paul Gofman pgofman@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;