Let the console renderer be defined as a thread.
diff --git a/server/console.c b/server/console.c
index 4ea264e..16fe874 100644
--- a/server/console.c
+++ b/server/console.c
@@ -180,7 +180,7 @@
return evt;
}
-static struct object *create_console_input( struct process* renderer )
+static struct object *create_console_input( struct thread* renderer )
{
struct console_input *console_input;
@@ -310,9 +310,10 @@
* 2/ parent is a renderer which launches process, and process should attach to the console
* renderered by parent
*/
-void inherit_console(struct process *parent, struct process *process, handle_t hconin)
+void inherit_console(struct thread *parent_thread, struct process *process, handle_t hconin)
{
int done = 0;
+ struct process* parent = parent_thread->process;
/* if parent is a renderer, then attach current process to its console
* a bit hacky....
@@ -323,7 +324,7 @@
if ((console = (struct console_input*)get_handle_obj( parent, hconin, 0, NULL )))
{
- if (console->renderer == parent)
+ if (console->renderer == parent_thread)
{
process->console = (struct console_input*)grab_object( console );
process->console->num_proc++;
@@ -1097,7 +1098,7 @@
goto the_end;
}
- if ((console = (struct console_input*)create_console_input( renderer )))
+ if ((console = (struct console_input*)create_console_input( current )))
{
if ((in = alloc_handle( renderer, console, req->access, req->inherit )))
{
diff --git a/server/console.h b/server/console.h
index bde68ec..9daed71 100644
--- a/server/console.h
+++ b/server/console.h
@@ -16,7 +16,7 @@
{
struct object obj; /* object header */
int num_proc; /* number of processes attached to this console */
- struct process *renderer; /* console renderer thread */
+ struct thread *renderer; /* console renderer thread */
int mode; /* input mode */
struct screen_buffer *active; /* active screen buffer */
int recnum; /* number of input records */
@@ -31,7 +31,7 @@
/* console functions */
-extern void inherit_console(struct process *parent, struct process *process, handle_t hconin);
+extern void inherit_console(struct thread *parent_thread, struct process *process, handle_t hconin);
extern int free_console( struct process *process );
#endif /* __WINE_SERVER_CONSOLE_H */
diff --git a/server/debugger.c b/server/debugger.c
index d4ea49d..3790292 100644
--- a/server/debugger.c
+++ b/server/debugger.c
@@ -413,9 +413,8 @@
if (thread->process == process) goto error;
/* don't let a debugger debug its console... won't work */
- if (debugger->process->console &&
- debugger->process->console->renderer == process &&
- process->console) goto error;
+ if (debugger->process->console && debugger->process->console->renderer->process == process)
+ goto error;
suspend_process( process );
diff --git a/server/process.c b/server/process.c
index 5a5241d..9643aaf 100644
--- a/server/process.c
+++ b/server/process.c
@@ -97,7 +97,7 @@
/* set the console and stdio handles for a newly created process */
-static int set_process_console( struct process *process, struct process *parent,
+static int set_process_console( struct process *process, struct thread *parent_thread,
struct startup_info *info, struct init_process_reply *reply )
{
if (process->create_flags & CREATE_NEW_CONSOLE)
@@ -105,26 +105,26 @@
/* let the process init do the allocation */
return 1;
}
- else if (parent && !(process->create_flags & DETACHED_PROCESS))
+ else if (parent_thread && !(process->create_flags & DETACHED_PROCESS))
{
/* FIXME: some better error checking should be done...
* like if hConOut and hConIn are console handles, then they should be on the same
* physical console
*/
- inherit_console( parent, process,
+ inherit_console( parent_thread, process,
(info->inherit_all || (info->start_flags & STARTF_USESTDHANDLES)) ?
info->hstdin : 0 );
}
- if (parent)
+ if (parent_thread)
{
if (!info->inherit_all && !(info->start_flags & STARTF_USESTDHANDLES))
{
/* duplicate the handle from the parent into this process */
- reply->hstdin = duplicate_handle( parent, info->hstdin, process,
+ reply->hstdin = duplicate_handle( parent_thread->process, info->hstdin, process,
0, TRUE, DUPLICATE_SAME_ACCESS );
- reply->hstdout = duplicate_handle( parent, info->hstdout, process,
+ reply->hstdout = duplicate_handle( parent_thread->process, info->hstdout, process,
0, TRUE, DUPLICATE_SAME_ACCESS );
- reply->hstderr = duplicate_handle( parent, info->hstderr, process,
+ reply->hstderr = duplicate_handle( parent_thread->process, info->hstderr, process,
0, TRUE, DUPLICATE_SAME_ACCESS );
}
else
@@ -260,7 +260,7 @@
}
/* set the process console */
- if (!set_process_console( process, parent, info, reply )) return;
+ if (!set_process_console( process, parent_thread, info, reply )) return;
if (parent)
{
@@ -434,7 +434,7 @@
}
/* kill all processes being attached to a console renderer */
-static void kill_console_processes( struct process *renderer, int exit_code )
+void kill_console_processes( struct thread *renderer, int exit_code )
{
for (;;) /* restart from the beginning of the list every time */
{
@@ -442,7 +442,7 @@
/* find the first process being attached to 'renderer' and still running */
while (process &&
- (process == renderer || !process->console ||
+ (process == renderer->process || !process->console ||
process->console->renderer != renderer || !process->running_threads))
{
process = process->next;
@@ -463,9 +463,6 @@
/* close the console attached to this process, if any */
free_console( process );
- /* close the processes using process as renderer, if any */
- kill_console_processes( process, 0 );
-
while (process->exe.next)
{
struct process_dll *dll = process->exe.next;
diff --git a/server/process.h b/server/process.h
index d17cb11..cc2dc98 100644
--- a/server/process.h
+++ b/server/process.h
@@ -78,6 +78,7 @@
extern void suspend_process( struct process *process );
extern void resume_process( struct process *process );
extern void kill_process( struct process *process, struct thread *skip, int exit_code );
+extern void kill_console_processes( struct thread *renderer, int exit_code );
extern void kill_debugged_processes( struct thread *debugger, int exit_code );
extern struct process_snapshot *process_snap( int *count );
extern struct module_snapshot *module_snap( struct process *process, int *count );
diff --git a/server/thread.c b/server/thread.c
index c568750..ff1e652 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -698,6 +698,7 @@
/* if it is waiting on the socket, we don't need to send a SIGTERM */
violent_death = 0;
}
+ kill_console_processes( thread, 0 );
debug_exit_thread( thread );
abandon_mutexes( thread );
remove_process_thread( thread->process, thread );