server: Make terminate_process more robust against recursive calls for the same process.

This commit is contained in:
Alexandre Julliard 2010-02-01 16:22:53 +01:00
parent 5c9753e2b6
commit 349eba9e09
1 changed files with 6 additions and 12 deletions

View File

@ -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 );
}