diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c index d11919643fb..e4176b591ff 100644 --- a/dlls/kernel32/tests/loader.c +++ b/dlls/kernel32/tests/loader.c @@ -1525,7 +1525,6 @@ static void child_process(const char *dll_name, DWORD target_offset) SetLastError(0xdeadbeef); thread = CreateThread(NULL, 0, noop_thread_proc, &dummy, 0, &ret); -todo_wine ok(!thread || broken(thread != 0) /* before win7 */, "CreateThread should fail\n"); if (!thread) ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError()); diff --git a/server/process.c b/server/process.c index 74a289a5c8d..89c08dc6da5 100644 --- a/server/process.c +++ b/server/process.c @@ -323,6 +323,7 @@ struct thread *create_process( int fd, struct thread *parent_thread, int inherit process->suspend = 0; process->is_system = 0; process->debug_children = 0; + process->is_terminating = 0; process->console = NULL; process->startup_state = STARTUP_IN_PROGRESS; process->startup_info = NULL; @@ -570,6 +571,8 @@ static void terminate_process( struct process *process, struct thread *skip, int struct thread *thread; grab_object( process ); /* make sure it doesn't get freed when threads die */ + process->is_terminating = 1; + restart: LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry ) { diff --git a/server/process.h b/server/process.h index f216ecdaae5..a50b5373862 100644 --- a/server/process.h +++ b/server/process.h @@ -74,6 +74,7 @@ struct process int suspend; /* global process suspend count */ unsigned int is_system:1; /* is it a system process? */ unsigned int debug_children:1;/* also debug all child processes */ + unsigned int is_terminating:1;/* is process terminating? */ struct list locks; /* list of file locks owned by the process */ struct list classes; /* window classes owned by the process */ struct console_input*console; /* console input */ diff --git a/server/thread.c b/server/thread.c index 69d547c1c56..b54b3b1550a 100644 --- a/server/thread.c +++ b/server/thread.c @@ -214,6 +214,12 @@ struct thread *create_thread( int fd, struct process *process ) { struct thread *thread; + if (process->is_terminating) + { + set_error( STATUS_PROCESS_IS_TERMINATING ); + return NULL; + } + if (!(thread = alloc_object( &thread_ops ))) return NULL; init_thread_structure( thread );