Commit 3940d8a2 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Let the console renderer be defined as a thread.

parent ffc61c80
......@@ -180,7 +180,7 @@ static struct console_input_events *create_console_input_events(void)
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 @@ int free_console( struct process *process )
* 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 @@ void inherit_console(struct process *parent, struct process *process, handle_t h
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 @@ DECL_HANDLER(alloc_console)
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 )))
{
......
......@@ -16,7 +16,7 @@ struct console_input
{
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 @@ struct console_input
/* 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 */
......@@ -413,9 +413,8 @@ static int debugger_attach( struct process *process, struct thread *debugger )
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 );
......
......@@ -97,7 +97,7 @@ static const struct object_ops startup_info_ops =
/* 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 @@ static int set_process_console( struct process *process, struct process *parent,
/* 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 @@ static void init_process( int ppid, struct init_process_reply *reply )
}
/* 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 @@ static void process_unload_dll( struct process *process, void *base )
}
/* 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 @@ static void kill_console_processes( struct process *renderer, int exit_code )
/* 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 @@ static void process_killed( struct process *process )
/* 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;
......
......@@ -78,6 +78,7 @@ extern void remove_process_thread( struct process *process,
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 );
......
......@@ -698,6 +698,7 @@ void kill_thread( struct thread *thread, int violent_death )
/* 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 );
......
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