kernelbase: Use conhost to handle Unix consoles.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0957f9302c
commit
54e117018c
|
@ -1656,11 +1656,18 @@ static HANDLE create_pseudo_console( COORD size, HANDLE input, HANDLE output, HA
|
||||||
si.StartupInfo.hStdError = output;
|
si.StartupInfo.hStdError = output;
|
||||||
si.StartupInfo.dwFlags = STARTF_USESTDHANDLES;
|
si.StartupInfo.dwFlags = STARTF_USESTDHANDLES;
|
||||||
swprintf( conhost_path, ARRAY_SIZE(conhost_path), L"%s\\conhost.exe", system_dir );
|
swprintf( conhost_path, ARRAY_SIZE(conhost_path), L"%s\\conhost.exe", system_dir );
|
||||||
swprintf( cmd, ARRAY_SIZE(cmd),
|
if (signal)
|
||||||
L"\"%s\" --headless %s--width %u --height %u --signal 0x%x --server 0x%x",
|
{
|
||||||
conhost_path, (flags & PSEUDOCONSOLE_INHERIT_CURSOR) ? L"--inheritcursor " : L"",
|
swprintf( cmd, ARRAY_SIZE(cmd),
|
||||||
size.X, size.Y, signal, server );
|
L"\"%s\" --headless %s--width %u --height %u --signal 0x%x --server 0x%x",
|
||||||
|
conhost_path, (flags & PSEUDOCONSOLE_INHERIT_CURSOR) ? L"--inheritcursor " : L"",
|
||||||
|
size.X, size.Y, signal, server );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
swprintf( cmd, ARRAY_SIZE(cmd), L"\"%s\" --unix --width %u --height %u --server 0x%x",
|
||||||
|
conhost_path, size.X, size.Y, server );
|
||||||
|
}
|
||||||
Wow64DisableWow64FsRedirection( &redir );
|
Wow64DisableWow64FsRedirection( &redir );
|
||||||
res = CreateProcessW( conhost_path, cmd, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL,
|
res = CreateProcessW( conhost_path, cmd, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL,
|
||||||
&si.StartupInfo, &pi );
|
&si.StartupInfo, &pi );
|
||||||
|
@ -1745,11 +1752,52 @@ HRESULT WINAPI ResizePseudoConsole( HPCON handle, COORD size )
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL is_tty_handle( HANDLE handle )
|
||||||
|
{
|
||||||
|
return ((UINT_PTR)handle & 3) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
void init_console( void )
|
void init_console( void )
|
||||||
{
|
{
|
||||||
RTL_USER_PROCESS_PARAMETERS *params = RtlGetCurrentPeb()->ProcessParameters;
|
RTL_USER_PROCESS_PARAMETERS *params = RtlGetCurrentPeb()->ProcessParameters;
|
||||||
|
|
||||||
if (params->ConsoleHandle == CONSOLE_HANDLE_ALLOC)
|
if (params->ConsoleHandle == CONSOLE_HANDLE_SHELL)
|
||||||
|
{
|
||||||
|
HANDLE tty_in = NULL, tty_out = NULL, process = NULL;
|
||||||
|
COORD size;
|
||||||
|
|
||||||
|
if (is_tty_handle( params->hStdInput ))
|
||||||
|
{
|
||||||
|
tty_in = params->hStdInput;
|
||||||
|
params->hStdInput = NULL;
|
||||||
|
}
|
||||||
|
if (is_tty_handle( params->hStdOutput ))
|
||||||
|
{
|
||||||
|
tty_out = params->hStdOutput;
|
||||||
|
params->hStdOutput = NULL;
|
||||||
|
}
|
||||||
|
if (is_tty_handle( params->hStdError ))
|
||||||
|
{
|
||||||
|
if (tty_out) CloseHandle( params->hStdError );
|
||||||
|
else tty_out = params->hStdError;
|
||||||
|
params->hStdError = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size.X = params->dwXCountChars;
|
||||||
|
size.Y = params->dwYCountChars;
|
||||||
|
TRACE( "creating unix console (size %u %u)\n", size.X, size.Y );
|
||||||
|
params->ConsoleHandle = create_pseudo_console( size, tty_in, tty_out, NULL, 0, &process );
|
||||||
|
CloseHandle( process );
|
||||||
|
CloseHandle( tty_in );
|
||||||
|
CloseHandle( tty_out );
|
||||||
|
|
||||||
|
if (params->ConsoleHandle && create_console_connection( params->ConsoleHandle ))
|
||||||
|
{
|
||||||
|
init_console_std_handles( FALSE );
|
||||||
|
console_flags = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (params->ConsoleHandle == CONSOLE_HANDLE_ALLOC)
|
||||||
{
|
{
|
||||||
HMODULE mod = GetModuleHandleW( NULL );
|
HMODULE mod = GetModuleHandleW( NULL );
|
||||||
params->ConsoleHandle = NULL;
|
params->ConsoleHandle = NULL;
|
||||||
|
|
|
@ -1156,12 +1156,29 @@ NTSTATUS CDECL get_dynamic_environment( WCHAR *env, SIZE_T *size )
|
||||||
void CDECL get_initial_console( RTL_USER_PROCESS_PARAMETERS *params )
|
void CDECL get_initial_console( RTL_USER_PROCESS_PARAMETERS *params )
|
||||||
{
|
{
|
||||||
int output_fd = -1;
|
int output_fd = -1;
|
||||||
if (isatty(0) || isatty(1) || isatty(2)) params->ConsoleHandle = CONSOLE_HANDLE_SHELL;
|
|
||||||
if (!isatty(0)) wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdInput );
|
wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdInput );
|
||||||
if (!isatty(2)) wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdError );
|
wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdOutput );
|
||||||
else output_fd = 2;
|
wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdError );
|
||||||
if (!isatty(1)) wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdOutput );
|
|
||||||
else output_fd = 1;
|
/* mark tty handles for kernelbase, see init_console */
|
||||||
|
if (params->hStdInput && isatty(0))
|
||||||
|
{
|
||||||
|
params->ConsoleHandle = CONSOLE_HANDLE_SHELL;
|
||||||
|
params->hStdInput = (HANDLE)((UINT_PTR)params->hStdInput | 1);
|
||||||
|
}
|
||||||
|
if (params->hStdError && isatty(2))
|
||||||
|
{
|
||||||
|
params->ConsoleHandle = CONSOLE_HANDLE_SHELL;
|
||||||
|
params->hStdError = (HANDLE)((UINT_PTR)params->hStdError | 1);
|
||||||
|
output_fd = 2;
|
||||||
|
}
|
||||||
|
if (params->hStdOutput && isatty(1))
|
||||||
|
{
|
||||||
|
params->ConsoleHandle = CONSOLE_HANDLE_SHELL;
|
||||||
|
params->hStdOutput = (HANDLE)((UINT_PTR)params->hStdOutput | 1);
|
||||||
|
output_fd = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (output_fd != -1)
|
if (output_fd != -1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue