From 349eba9e0944c24cfd6623f063b84a05adba6dcb Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 1 Feb 2010 16:22:53 +0100 Subject: [PATCH] server: Make terminate_process more robust against recursive calls for the same process. --- server/process.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/server/process.c b/server/process.c index 379bec69723..e4dca68cb5b 100644 --- a/server/process.c +++ b/server/process.c @@ -562,23 +562,17 @@ static void process_unload_dll( struct process *process, mod_handle_t base ) /* terminate a process with the given exit code */ static void terminate_process( struct process *process, struct thread *skip, int exit_code ) { - struct list *ptr; - - if (skip && skip->process == process) /* move it to the end of the list */ - { - assert( skip->state != TERMINATED ); - list_remove( &skip->proc_entry ); - list_add_tail( &process->thread_list, &skip->proc_entry ); - } + struct thread *thread; grab_object( process ); /* make sure it doesn't get freed when threads die */ - while ((ptr = list_head( &process->thread_list ))) +restart: + LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry ) { - struct thread *thread = LIST_ENTRY( ptr, struct thread, proc_entry ); - if (exit_code) thread->exit_code = exit_code; - if (thread == skip) break; + if (thread == skip) continue; + if (thread->state == TERMINATED) continue; kill_thread( thread, 1 ); + goto restart; } release_object( process ); } -- 2.11.4.GIT