ntdll: Don't create Unix console for GUI apps.

Note: GUI apps using std I/O (this is not common) will
no longer print on unix console.
If such a behavior is needed, for an app started from
Unix shell, one can either redirect output to a file, or pipe output:
./wine app | cat

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
This commit is contained in:
Eric Pouech 2023-11-17 11:54:18 +01:00 committed by Alexandre Julliard
parent 1f478ea370
commit 4b63e88894
2 changed files with 8 additions and 2 deletions

View file

@ -1396,6 +1396,9 @@ static void get_initial_console( RTL_USER_PROCESS_PARAMETERS *params )
wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, &params->hStdOutput );
wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, &params->hStdError );
if (main_image_info.SubSystemType != IMAGE_SUBSYSTEM_WINDOWS_CUI)
return;
/* mark tty handles for kernelbase, see init_console */
if (params->hStdInput && isatty(0))
{
@ -1414,7 +1417,7 @@ static void get_initial_console( RTL_USER_PROCESS_PARAMETERS *params )
params->hStdOutput = (HANDLE)((UINT_PTR)params->hStdOutput | 1);
output_fd = 1;
}
if (!params->ConsoleHandle && main_image_info.SubSystemType == IMAGE_SUBSYSTEM_WINDOWS_CUI)
if (!params->ConsoleHandle)
params->ConsoleHandle = CONSOLE_HANDLE_SHELL_NO_WINDOW;
if (output_fd != -1)

View file

@ -401,6 +401,7 @@ static struct
WCHAR *title;
DWORD creation_flags;
USHORT machine;
BOOL cp_inherit;
} opts;
static void parse_command_line( int argc, WCHAR *argv[] )
@ -416,6 +417,7 @@ static void parse_command_line( int argc, WCHAR *argv[] )
/* Dunno what these mean, but it looks like winMe's start uses them */
opts.sei.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI;
opts.creation_flags = CREATE_NEW_CONSOLE;
opts.cp_inherit = FALSE;
/* Canonical Microsoft commandline flag processing:
* flags start with / and are case insensitive.
@ -490,6 +492,7 @@ static void parse_command_line( int argc, WCHAR *argv[] )
else if (is_option(argv[i], L"/exec")) {
opts.creation_flags = 0;
opts.sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE | SEE_MASK_FLAG_NO_UI;
opts.cp_inherit = TRUE;
i++;
break;
}
@ -581,7 +584,7 @@ int __cdecl wmain (int argc, WCHAR *argv[])
si.StartupInfo.dwFlags |= STARTF_USESHOWWINDOW;
si.StartupInfo.lpTitle = opts.title;
if (!CreateProcessW( opts.sei.lpFile, commandline, NULL, NULL, FALSE,
if (!CreateProcessW( opts.sei.lpFile, commandline, NULL, NULL, opts.cp_inherit,
opts.creation_flags, NULL, opts.sei.lpDirectory,
&si.StartupInfo, &process_information ))
{