Commit af3d73b0 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

server: Add a process flag indicating whether the process is terminating, use it…

server: Add a process flag indicating whether the process is terminating, use it to block thread creation in a being terminated process.
parent 1a697e15
...@@ -1525,7 +1525,6 @@ static void child_process(const char *dll_name, DWORD target_offset) ...@@ -1525,7 +1525,6 @@ static void child_process(const char *dll_name, DWORD target_offset)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
thread = CreateThread(NULL, 0, noop_thread_proc, &dummy, 0, &ret); thread = CreateThread(NULL, 0, noop_thread_proc, &dummy, 0, &ret);
todo_wine
ok(!thread || broken(thread != 0) /* before win7 */, "CreateThread should fail\n"); ok(!thread || broken(thread != 0) /* before win7 */, "CreateThread should fail\n");
if (!thread) if (!thread)
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError()); ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
......
...@@ -323,6 +323,7 @@ struct thread *create_process( int fd, struct thread *parent_thread, int inherit ...@@ -323,6 +323,7 @@ struct thread *create_process( int fd, struct thread *parent_thread, int inherit
process->suspend = 0; process->suspend = 0;
process->is_system = 0; process->is_system = 0;
process->debug_children = 0; process->debug_children = 0;
process->is_terminating = 0;
process->console = NULL; process->console = NULL;
process->startup_state = STARTUP_IN_PROGRESS; process->startup_state = STARTUP_IN_PROGRESS;
process->startup_info = NULL; process->startup_info = NULL;
...@@ -570,6 +571,8 @@ static void terminate_process( struct process *process, struct thread *skip, int ...@@ -570,6 +571,8 @@ static void terminate_process( struct process *process, struct thread *skip, int
struct thread *thread; struct thread *thread;
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 */
process->is_terminating = 1;
restart: restart:
LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry ) LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
{ {
......
...@@ -74,6 +74,7 @@ struct process ...@@ -74,6 +74,7 @@ struct process
int suspend; /* global process suspend count */ int suspend; /* global process suspend count */
unsigned int is_system:1; /* is it a system process? */ unsigned int is_system:1; /* is it a system process? */
unsigned int debug_children:1;/* also debug all child processes */ 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 locks; /* list of file locks owned by the process */
struct list classes; /* window classes owned by the process */ struct list classes; /* window classes owned by the process */
struct console_input*console; /* console input */ struct console_input*console; /* console input */
......
...@@ -214,6 +214,12 @@ struct thread *create_thread( int fd, struct process *process ) ...@@ -214,6 +214,12 @@ struct thread *create_thread( int fd, struct process *process )
{ {
struct thread *thread; struct thread *thread;
if (process->is_terminating)
{
set_error( STATUS_PROCESS_IS_TERMINATING );
return NULL;
}
if (!(thread = alloc_object( &thread_ops ))) return NULL; if (!(thread = alloc_object( &thread_ops ))) return NULL;
init_thread_structure( thread ); init_thread_structure( thread );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment