server: Make terminate_process more robust against recursive calls for the same process.
This commit is contained in:
parent
5c9753e2b6
commit
349eba9e09
|
@ -562,23 +562,17 @@ static void process_unload_dll( struct process *process, mod_handle_t base )
|
||||||
/* terminate a process with the given exit code */
|
/* terminate a process with the given exit code */
|
||||||
static void terminate_process( struct process *process, struct thread *skip, int exit_code )
|
static void terminate_process( struct process *process, struct thread *skip, int exit_code )
|
||||||
{
|
{
|
||||||
struct list *ptr;
|
struct thread *thread;
|
||||||
|
|
||||||
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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
grab_object( process ); /* make sure it doesn't get freed when threads die */
|
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 (exit_code) thread->exit_code = exit_code;
|
||||||
if (thread == skip) break;
|
if (thread == skip) continue;
|
||||||
|
if (thread->state == TERMINATED) continue;
|
||||||
kill_thread( thread, 1 );
|
kill_thread( thread, 1 );
|
||||||
|
goto restart;
|
||||||
}
|
}
|
||||||
release_object( process );
|
release_object( process );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue