Commit 30596feb authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

server: Use passed console handle to inherit console for created process.

parent ca30fa5c
......@@ -193,6 +193,7 @@ static RTL_USER_PROCESS_PARAMETERS *create_process_params( const WCHAR *filename
if (flags & CREATE_NEW_PROCESS_GROUP) params->ConsoleFlags = 1;
if (flags & CREATE_NEW_CONSOLE) params->ConsoleHandle = (HANDLE)1; /* KERNEL32_CONSOLE_ALLOC */
else if (!(flags & DETACHED_PROCESS)) params->ConsoleHandle = NtCurrentTeb()->Peb->ProcessParameters->ConsoleHandle;
if (startup->dwFlags & STARTF_USESTDHANDLES)
{
......
......@@ -620,40 +620,29 @@ int free_console( struct process *process )
* 2/ parent is a renderer which launches process, and process should attach to the console
* rendered by parent
*/
obj_handle_t inherit_console( struct thread *parent_thread, struct process *parent, struct process *process,
obj_handle_t inherit_console( struct thread *parent_thread, obj_handle_t handle, struct process *process,
obj_handle_t hconin )
{
int done = 0;
struct console_input *console = NULL;
if (handle && !(console = (struct console_input *)get_handle_obj( current->process, handle, 0,
&console_input_ops )))
return 0;
/* if parent is a renderer, then attach current process to its console
* a bit hacky....
*/
if (hconin && parent_thread)
if (!console && hconin && parent_thread)
{
struct console_input *console;
/* FIXME: should we check some access rights ? */
if ((console = (struct console_input *)get_handle_obj( parent, hconin,
0, &console_input_ops )))
{
if (console->renderer == parent_thread)
{
process->console = (struct console_input *)grab_object( console );
process->console->num_proc++;
done = 1;
}
release_object( console );
}
else clear_error(); /* ignore error */
}
/* otherwise, if parent has a console, attach child to this console */
if (!done && parent->console)
{
process->console = (struct console_input *)grab_object( parent->console );
process->console->num_proc++;
if (!(console = (struct console_input *)get_handle_obj( parent_thread->process, hconin,
0, &console_input_ops )))
clear_error(); /* ignore error */
}
if (!console) return 0;
if (!process->console) return 0;
process->console = console;
console->num_proc++;
return alloc_handle( process, process->console,
SYNCHRONIZE | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, 0 );
}
......
......@@ -1224,7 +1224,7 @@ DECL_HANDLER(new_process)
* like if hConOut and hConIn are console handles, then they should be on the same
* physical console
*/
info->data->console = inherit_console( parent_thread, parent,
info->data->console = inherit_console( parent_thread, info->data->console,
process, req->inherit_all ? info->data->hstdin : 0 );
}
......
......@@ -131,7 +131,7 @@ extern void detach_debugged_processes( struct thread *debugger );
extern void enum_processes( int (*cb)(struct process*, void*), void *user);
/* console functions */
extern obj_handle_t inherit_console( struct thread *parent_thread, struct process *parent,
extern obj_handle_t inherit_console( struct thread *parent_thread, obj_handle_t handle,
struct process *process, obj_handle_t hconin );
extern int free_console( struct process *process );
extern struct thread *console_get_renderer( struct console_input *console );
......
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